vendredi 4 mars 2016

Reseting websocket

I'm writing program that communicates through web sockets and sends serialized objects. I have problem in situation, when connection between server and client is lost. I get this exception:

java.net.SocketException: Connection reset by peer: socket write error
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:109)
at java.net.SocketOutputStream.write(SocketOutputStream.java:153)
at java.io.ObjectOutputStream$BlockDataOutputStream.drain(ObjectOutputStream.java:1877)
at java.io.ObjectOutputStream$BlockDataOutputStream.setBlockDataMode(ObjectOutputStream.java:1786)
at java.io.ObjectOutputStream.writeNonProxyDesc(ObjectOutputStream.java:1286)
at java.io.ObjectOutputStream.writeClassDesc(ObjectOutputStream.java:1231)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1427)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)
at java.io.ObjectOutputStream.writeFatalException(ObjectOutputStream.java:1577)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:351)
at common.WebSocketServer.sendResponse(WebSocketServer.java:103)
at common.WebSocketServer.listen(WebSocketServer.java:86)
at common.WebSocketServer.main(WebSocketServer.java:50)

When I use method socket.isConnected() to check, if server should abandon this client, it returns true (why?), even after closing socket and opening again it is still opened. What should I do?




Aucun commentaire:

Enregistrer un commentaire