Open GoogleCodeExporter opened 9 years ago
[deleted comment]
I have the same Error!
But I have tried to strip hessian from caucho by myself and had sucess. But
there I
have also the same error :-/ Any ideas?
Original comment by najjan...@gmail.com
on 2 Oct 2009 at 7:58
Hi guys, I think this problem is related to the issue other Android developers
are seeing here:
http://groups.google.com/group/android-developers/browse_thread/thread/bc5454ffc
71f77dc. I believe it
is related to HTTPUrlConnection's use (/misuse) of persistent connections and
response body's not being read
fully.
I stumbled across a similar, more serious issue in Hessdroid where if your
remote service throws an
exception, the next request to the service (even if you recreate the service
interface from scratch) will exhibit
the same behaviour.
It seems there are two workarounds to the problem:
The first is to set System.setProperty("http.keepAlive", "false") somewhere in
the code. The second is to retry
your connection if the response code comes back as -1.
Although option 2 seems ugly, option 1 loses the benefits of persistent
connections. Therefore by adding the
following code to the HessianProxy (circa line 170) I was able to workaround
the problem:
...
try {
code = httpConn.getResponseCode();
} catch (Exception e) {
}
parseResponseHeaders(conn);
if (code == -1)
{
int retries = 3;
int currentTry = 0;
while (code == -1 && currentTry < retries)
{
conn = sendRequest(mangleName, args);
httpConn = (HttpURLConnection) conn;
code = 500;
try {
code = httpConn.getResponseCode();
} catch (Exception e)
{
}
parseResponseHeaders(conn);
currentTry++;
}
}
if (code != 200) {
StringBuffer sb = new StringBuffer();
int ch;
...
This is similar to John Coryat's solution provided in the URL above. If anyone
has any improved suggestions
please let me know.
Cheers,
Robert
Original comment by robert.t...@googlemail.com
on 6 Oct 2009 at 3:17
i worked around using
BasicAPI api;
try {
proxyFactory.setHessian2Reply(false);
proxyFactory.setChunkedPost(true);
proxyFactory.setReadTimeout(30000);
proxyFactory.setDebug(true);//this line is the workaround
api = (BasicAPI) proxyFactory.create
Thanks and regards
Robin
@Katalytik Inc.
Original comment by roberto.robin@gmail.com
on 6 Oct 2009 at 5:12
Your solution is certainly better - in fact the one I proposed above is
outright wrong for anyone wishing to post
data to the server, since it will be posted multiple times. Don't use it! :)
Regards,
Robert
Original comment by robert.t...@googlemail.com
on 6 Oct 2009 at 8:21
Using proxyFactory.setDebug(true) as a workaround is not a good idea. A call
that
takes under 1 second without debug takes 15 seconds with debug set to true.
Looking at HessianProxyFactory's code, I see that if debug is true a
HessianDebugInputStream is used. HessianDebugInputStream prints all data to
System.out, which would be the main cause of the performance hit.
However, if I don't set debug to true I eventually get the
"com.caucho.hessian.client.HessianConnectionException: -1". I have yet to
determine
why that is.
Original comment by claes.bu...@gmail.com
on 7 Nov 2009 at 1:13
It looks like something is wrong in Android's
org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection.Chunked
InputStream.read(byte[]
buf, int offset, int length). When in debug mode, HessianDebugInputStream,
which
extends InputStream, is used instead. Since InputStream.read(byte[] buf, int
offset,
int length) is called instead, the problem is avoided.
However, debug mode gives unacceptable performance. I have found that a better
workaround is to disable debug mode and to disable chunked posts, which are
enabled
by default:
proxyFactory.setChunkedPost(false);
proxyFactory.setDebug(false);
This works for me.
Original comment by claes.bu...@gmail.com
on 7 Nov 2009 at 5:39
thanks guys. I had the same problem and using
proxyFactory.setChunkedPost(false);
proxyFactory.setDebug(false);
solved my issue
Fedeo
Original comment by federico...@gmail.com
on 25 Feb 2010 at 12:37
thanks guys. I had the same problem and using
proxyFactory.setChunkedPost(false);
proxyFactory.setDebug(false);
solved my issue
GOOD
Jia
Original comment by ncep...@googlemail.com
on 3 Aug 2013 at 2:24
Original issue reported on code.google.com by
roberto.robin@gmail.com
on 1 Sep 2009 at 7:56