[TYRUS-230] When Session is invalidated, the close reason is not 1006 Created: 08/Aug/13  Updated: 20/Feb/14  Resolved: 28/Aug/13

Status: Resolved
Project: tyrus
Component/s: None
Affects Version/s: 1.2.1
Fix Version/s: 1.3

Type: Bug Priority: Major
Reporter: jan.supol Assignee: stepan.kopriva
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to TYRUS-225 Invalidation of (Servlet) HttpSession... Resolved
is related to TYRUS-294 Close reason is not 1006 when connect... Resolved

 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;


Generated at Sun Mar 29 17:19:41 UTC 2015 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.