0

我正在使用 hessdroid 代理在我的 android 应用程序和我的 webservice/hessianservlet 之间进行通信。它在启动应用程序后立即运行,但是当我等待一分钟并让应用程序再次调用网络函数(例如 logout())时,我收到以下错误消息:

com.caucho.hessian.client.HessianConnectionException: 500: java.io.EOFException
    at com.caucho.hessian.client.HessianProxy.invoke(HessianProxy.java:197)
    at $Proxy1.getPassword(Native Method)
    at tsch.serviceApp.net.DataHandler.getPassword(DataHandler.java:50)
    at tsch.serviceApp.PageSystemApps$1$1.run(PageSystemApps.java:91)
 Caused by: java.io.EOFException
    at libcore.io.Streams.readAsciiLine(Streams.java:203)
    at libcore.net.http.HttpEngine.readResponseHeaders(HttpEngine.java:573)
    at libcore.net.http.HttpEngine.readResponse(HttpEngine.java:821)
    at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:283)
    at libcore.net.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:495)
    at com.caucho.hessian.client.HessianProxy.invoke(HessianProxy.java:167)

.

public String login() {
    HessianProxyFactory factory = new HessianProxyFactory();         
    String url = "http://192.168.56.1:8080/hessianServer";
    factory.setHessian2Reply(false); // avoid hessian reply error
    try {
        userCon = (IUserService) factory.create(IUserService.class, url+"/IUserService");                      
    } catch (MalformedURLException e) {
        e.printStackTrace();
    }
    return "Logged in!";
}

public void logout() {
    userCon.logout();
}
4

2 回答 2

1

我在 android 4.1 上遇到了同样的问题,但在 android 4.0.3 上没问题。我添加了一条语句“ conn.setRequestProperty("Connection", "Close");" 在 HessianProxyFactory 类的 openConnection 方法中。

protected URLConnection openConnection(URL url)
            throws IOException {
        URLConnection conn = url.openConnection();

        conn.setDoOutput(true);

        if (_readTimeout > 0) {
            try {
                conn.setReadTimeout((int) _readTimeout);
            } catch (Throwable e) { // intentionally empty
            }
        }

        conn.setRequestProperty("Content-Type", "x-application/hessian");

        conn.setRequestProperty("Connection", "Close");

        if (_basicAuth != null)
            conn.setRequestProperty("Authorization", _basicAuth);
        else if (_user != null && _password != null) {
            _basicAuth = "Basic " + base64(_user + ":" + _password);
            conn.setRequestProperty("Authorization", _basicAuth);
        }

        return conn;
    }

问题消失了。

于 2013-07-24T06:52:22.033 回答
0

使用Flamingo而不是 Hessdroid,一切正常!

于 2013-04-30T14:49:41.007 回答