codebutler / android-websockets

Bare minimum websockets (hybi13/RFC) client for Android
713 stars 494 forks source link

Calling disconnect throws exception #19

Open Umaid1 opened 10 years ago

Umaid1 commented 10 years ago

03-25 16:29:39.992: E/TAG(21060): java.net.SocketException: Socket closed 03-25 16:29:39.992: E/TAG(21060): at libcore.io.Posix.recvfromBytes(Native Method) 03-25 16:29:39.992: E/TAG(21060): at libcore.io.Posix.recvfrom(Posix.java:131) 03-25 16:29:39.992: E/TAG(21060): at libcore.io.BlockGuardOs.recvfrom(BlockGuardOs.java:164) 03-25 16:29:39.992: E/TAG(21060): at libcore.io.IoBridge.recvfrom(IoBridge.java:513) 03-25 16:29:39.992: E/TAG(21060): at java.net.PlainSocketImpl.read(PlainSocketImpl.java:488) 03-25 16:29:39.992: E/TAG(21060): at java.net.PlainSocketImpl.access$000(PlainSocketImpl.java:46) 03-25 16:29:39.992: E/TAG(21060): at java.net.PlainSocketImpl$PlainSocketInputStream.read(PlainSocketImpl.java:240) 03-25 16:29:39.992: E/TAG(21060): at libcore.io.Streams.readSingleByte(Streams.java:41) 03-25 16:29:39.992: E/TAG(21060): at java.net.PlainSocketImpl$PlainSocketInputStream.read(PlainSocketImpl.java:236) 03-25 16:29:39.992: E/TAG(21060): at java.io.DataInputStream.readByte(DataInputStream.java:96) 03-25 16:29:39.992: E/TAG(21060): at com.codebutler.android_websockets.HybiParser.start(HybiParser.java:112) 03-25 16:29:39.992: E/TAG(21060): at com.codebutler.android_websockets.WebSocketClient$1.run(WebSocketClient.java:134) 03-25 16:29:39.992: E/TAG(21060): at java.lang.Thread.run(Thread.java:856) 03-25 16:29:40.397: A/libc(21060): Fatal signal 11 (SIGSEGV) at 0x00000027 (code=1), thread 21065 (JDWP)

PEZ commented 10 years ago

I have a similar issue. Getting this when I close the socket:

D/WebSocketClient( 418): WebSocket EOF! D/WebSocketClient( 418): java.io.EOFException D/WebSocketClient( 418): at java.io.DataInputStream.readByte(DataInputStream.java:98) D/WebSocketClient( 418): at com.codebutler.android_websockets.HybiParser.start(HybiParser.java:112) D/WebSocketClient( 418): at com.codebutler.android_websockets.WebSocketClient$1.run(WebSocketClient.java:134) D/WebSocketClient( 418): at java.lang.Thread.run(Thread.java:856)

Seems like the stream.available() == -1 in HybiParser.java should guard against that?

109:            if (stream.available() == -1) break;
110:            switch (mStage) {
111:                case 0:
112:                    parseOpcode(stream.readByte());
113:                    break;
Umaid1 commented 10 years ago

Can you please tell me how did you resolved it?

mackong commented 10 years ago

I have this issue too, Did you solved it?

WashRinseRepeat commented 10 years ago

Hi, I'm also having this issue. It's a problem, because right now I cannot do proper error handling in the app, since I cannot distinguish between a clean close of the socket and a genuine error. I tried looking into the code, but I'm not proficient enough to actually solve this myself :/

vallivenkatesan commented 9 years ago

Can somebody tell how you solved this problem? Thanks in advance.

BooboNikita commented 4 years ago

109: if (stream.available() == -1) break; 110: switch (mStage) { 111: case 0: 112: if (stream.available() == -1) break; 113: parseOpcode(stream.readByte()); 114: break; I do like this and it may work.