android - Websocket.disconnect() method throws java.net.SocketException: Socket closed -
i using android-websockets library codebutler in project. ran problem when execute disconnect()
method. following code:
public void disconnectserver() { if(client != null) { try { if(client.isconnected()) { client.disconnect(); } } catch (exception e) { e.printstacktrace(); } } }
i following exception:
05-11 17:58:19.873: w/system.err(29443): java.net.socketexception: socket closed
05-11 17:58:19.873: w/system.err(29443): @ libcore.io.posix.recvfrombytes(native method)
05-11 17:58:19.873: w/system.err(29443): @ libcore.io.posix.recvfrom(posix.java:161)
05-11 17:58:19.873: w/system.err(29443): @ libcore.io.blockguardos.recvfrom(blockguardos.java:250)
05-11 17:58:19.878: w/system.err(29443): @ libcore.io.iobridge.recvfrom(iobridge.java:553)
05-11 17:58:19.878: w/system.err(29443): @ java.net.plainsocketimpl.read(plainsocketimpl.java:485)
05-11 17:58:19.878: w/system.err(29443): @ java.net.plainsocketimpl.access$000(plainsocketimpl.java:37)
05-11 17:58:19.878: w/system.err(29443): @ java.net.plainsocketimpl$plainsocketinputstream.read(plainsocketimpl.java:237)
05-11 17:58:19.878: w/system.err(29443): @ libcore.io.streams.readsinglebyte(streams.java:41)
05-11 17:58:19.878: w/system.err(29443): @ java.net.plainsocketimpl$plainsocketinputstream.read(plainsocketimpl.java:233)
05-11 17:58:19.878: w/system.err(29443): @ java.io.datainputstream.readbyte(datainputstream.java:75)
05-11 17:58:19.878: w/system.err(29443): @ com.codebutler.android_websockets.hybiparser.start(hybiparser.java:120)
05-11 17:58:19.878: w/system.err(29443): @ com.codebutler.android_websockets.websocketclient$1.run(websocketclient.java:145)
05-11 17:58:19.878: w/system.err(29443): @ java.lang.thread.run(thread.java:818)
please help!!!!!
it because implementation of disconnect() method not synchronize thread created in implementation of connect() method. codebutler/android-websockets not of commercial quality. disconnect() method not perform closing handshake required rfc 6455.
use websocket library if don't want see error.
Comments
Post a Comment