gusavila92/java-android-websocket-client

Unexpected end of stream

lgbm opened this issue · 8 comments

lgbm commented

Hello there!

A lot exceptions "Unexpected end of stream" is thrown in read() function (inputstream closing first?)
Is there any issues about this?

onTextReceived onTextReceived **Unexpected end of stream** onOpen onTextReceived onTextReceived onTextReceived onTextReceived onTextReceived onTextReceived onTextReceived onTextReceived onTextReceived onTextReceived **Unexpected end of stream** onOpen onTextReceived onTextReceived

Above, events log from your example.

Regards,
Luis Muniz

Hi!
Could you please tell me how are you testing this library? Is the library being executed within a mobile or desktop device? Which WebSocket version is your server running? Who decides to close the connection, your client or your server?

lgbm commented

ws://echo.websocket.org
Desktop, Java SE
I guess with idle connection, but your library try to reconnect after 60s (read timeout)

I'm testing here and no problems so far. Can you tell me what version are you using?

lgbm commented

java-android-websocket-client version? Last.
java version? jdk1.8.0_131

Please, check out this: https://pastebin.com/u0JFKBP9
The "Unexpected end of stream" exception occur after some minutes (totally random)

Logs:

2017-12-21T13:43:02.947: onOpen
2017-12-21T13:43:03.346: onTextReceived
2017-12-21T13:43:05.948: onTextReceived
2017-12-21T13:43:08.182: onTextReceived
2017-12-21T13:43:11.283: onTextReceived
............
2017-12-21T13:52:56.235: onTextReceived
2017-12-21T13:53:00.766: onTextReceived
2017-12-21T13:53:02.947: Unexpected end of stream

I tested the library in my computer connecting to your server and everything is working fine. I managed to receive JSON text for 10 minutes or more without getting the "Unexpected end of stream". I recommend you to check any proxies or routers in between that could be killing the connection, because some of them kill long standing connections even if those connections are receiving data.

P.D. You should implement some kind of authentication technique, because anyone can watch your server data.

lgbm commented

You have tested with https://pastebin.com/u0JFKBP9 ?

Yes, with the same code that you pasted there.

lgbm commented

I suppose, the server side kill the connection due idle connection or something else.
Always 10 min each, a lot of coincidence for nothing.

My connection is directly, no proxies, no bridges, no firewall or AV intromissions.

Thank you for support.