tyrus
  1. tyrus
  2. TYRUS-230

When Session is invalidated, the close reason is not 1006

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.2.1
    • Fix Version/s: 1.3
    • Component/s: None
    • Labels:
      None

      Description

      Spec says (Section 2.1.5):

      If the close was initiated by the local container, for example if the local
      container determines the session has timed out, the local implementation must use the websocket protocol
      close code 1006.

      Having the following endpoint:

      @ServerEndpoint(value = "/closesession")
      public class WSCCloseSessionServer {
      static int lastCloseCode = 0;
      	@OnMessage
      	public String onMessage(String msg, Session session) {
                      if ("idle".equals(msg)) {
      			lastCloseCode = 0;
      			session.setMaxIdleTimeout(1);
      		} else if ("code".equals(msg))
      			msg = String.valueOf(lastCloseCode);
      		return msg;
      	}
      	@OnClose
      	public void onClose(CloseReason reason) {
      		lastCloseCode = reason.getCloseCode().getCode();
      		String msg = "Close code: " + lastCloseCode;
      		System.out.println(msg);
      	}
      }
      

      After request with "idle" message,
      @OnClose writes down code 1000;

        Issue Links

          Activity

          There are no comments yet on this issue.

            People

            • Assignee:
              stepan.kopriva
              Reporter:
              jan.supol
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: