Skip to content

Commit

Permalink
Close the channel on manual disconnect
Browse files Browse the repository at this point in the history
Close the socket channel on manual disconnect() – otherwise channel remains opened and isConnected() will return true but no further request will succeed.
  • Loading branch information
almozavr committed Aug 26, 2014
1 parent f711039 commit 334cd9f
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion Autobahn/src/de/tavendo/autobahn/WebSocketConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,17 @@ public void handleMessage(Message msg) {
final int tavendoCloseCode = (close.mCode == 1000) ? ConnectionHandler.CLOSE_NORMAL : ConnectionHandler.CLOSE_CONNECTION_LOST;
onClose(tavendoCloseCode, close.mReason);

mWriter.forward(new WebSocketMessage.Close(1000));
if (mActive) {
mWriter.forward(new WebSocketMessage.Close(1000));
} else {
// we've initiated disconnect, so ready to close the channel
try {
mTransportChannel.close();
} catch (IOException e) {
if (DEBUG) e.printStackTrace();
}
}


} else if (msg.obj instanceof WebSocketMessage.ServerHandshake) {

Expand Down

0 comments on commit 334cd9f

Please sign in to comment.