Skip to content

Commit

Permalink
Add some debug logging to the WebSocket session to track creation and…
Browse files Browse the repository at this point in the history
… closure

git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc7.0.x/trunk@1654788 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
markt-asf committed Jan 26, 2015
1 parent f03a65c commit 2b7b628
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
4 changes: 3 additions & 1 deletion java/org/apache/tomcat/websocket/LocalStrings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,15 @@ wsRemoteEndpoint.tooMuchData=Ping or pong may not send more than 125 bytes
wsSession.timeout=The WebSocket session timeout expired

wsSession.closed=The WebSocket session [{0}] has been closed and no method (apart from close()) may be called on a closed session
wsSession.created=Created WebSocket session [{0}]
wsSession.doClose=Closing WebSocket session [{1}]
wsSession.duplicateHandlerBinary=A binary message handler has already been configured
wsSession.duplicateHandlerPong=A pong message handler has already been configured
wsSession.duplicateHandlerText=A text message handler has already been configured
wsSession.invalidHandlerTypePong=A pong message handler must implement MessageHandler.Basic
wsSession.flushFailOnClose=Failed to flush batched messages on session close
wsSession.messageFailed=Unable to write the complete message as the WebSocket connection has been closed
wsSession.sendCloseFail=Failed to send close message to remote endpoint
wsSession.sendCloseFail=Failed to send close message for session [{0}] to remote endpoint
wsSession.removeHandlerFailed=Unable to remove the handler [{0}] as it was not registered with this session
wsSession.unknownHandler=Unable to add the message handler [{0}] as it was for the unrecognised type [{1}]
wsSession.unknownHandlerType=Unable to add the message handler [{0}] as it was wrapped as the unrecognised type [{1}]
Expand Down
9 changes: 8 additions & 1 deletion java/org/apache/tomcat/websocket/WsSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ public WsSession(Endpoint localEndpoint,

this.userProperties.putAll(endpointConfig.getUserProperties());
this.id = Long.toHexString(ids.getAndIncrement());

if (log.isDebugEnabled()) {
log.debug(sm.getString("wsSession.created", id));
}
}


Expand Down Expand Up @@ -436,6 +440,9 @@ private void doClose(CloseReason closeReasonMessage,
return;
}

if (log.isDebugEnabled()) {
log.debug(sm.getString("wsSession.doClose", id));
}
try {
wsRemoteEndpoint.setBatchingAllowed(false);
} catch (IOException e) {
Expand Down Expand Up @@ -540,7 +547,7 @@ private void sendCloseMessage(CloseReason closeReason) {
// Failed to send close message. Close the socket and let the caller
// deal with the Exception
if (log.isDebugEnabled()) {
log.debug(sm.getString("wsSession.sendCloseFail"), ioe);
log.debug(sm.getString("wsSession.sendCloseFail", id), ioe);
}
wsRemoteEndpoint.close();
// Failure to send a close message is not unexpected in the case of
Expand Down
4 changes: 4 additions & 0 deletions webapps/docs/changelog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,10 @@
within a web application when running under a SecurityManager. Based on
a patch by Mikael Sterner. (markt)
</fix>
<add>
Add some debug logging to the WebSocket session to track session
creation and session closure. (markt)
</add>
</changelog>
</subsection>
<subsection name="Web applications">
Expand Down

0 comments on commit 2b7b628

Please sign in to comment.