Used Flamingo instead of Hessdroid and everything works fine!
HessianConnectionException: 500 Caused by: java.io.EOFException (Android)
-
13-04-2022 - |
Question
I'm using a hessdroid proxy to communicate between my android application and my webservice/hessianservlet. It works immediatly after starting the app, but when I wait a minute and let the app call a network function again (e.g. logout()) I get this error message:
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();
}
Solution 2
OTHER TIPS
I runned into the same problem on android 4.1 ,but it's ok on android 4.0.3. I added a statement " conn.setRequestProperty("Connection", "Close");" in method openConnection of class HessianProxyFactory.
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;
}
and the problem disappeared.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow