gusavila92 / java-android-websocket-client

Java/Android WebSocket Client
Apache License 2.0
148 stars 38 forks source link

Unexpected end of stream #6

Closed lgbm closed 6 years ago

lgbm commented 6 years ago

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

gusavila92 commented 6 years ago

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 6 years ago

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

gusavila92 commented 6 years ago

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

lgbm commented 6 years ago

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

gusavila92 commented 6 years ago

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 6 years ago

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

gusavila92 commented 6 years ago

Yes, with the same code that you pasted there.

lgbm commented 6 years ago

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.