websocket subprotocols

36 views
Skip to first unread message

Vince Callaway

unread,
Nov 1, 2017, 8:11:14 PM11/1/17
to sparkjava
I've been playing with the websocket function and have run into a snag.

I want to setup a subprotocol but keep getting a null pointer error.

Here is a sample snippet of code in @OnWebsocketConnect

        if(session.getUpgradeRequest().hasSubProtocol("test1.0")) {

         UpgradeResponse res = session.getUpgradeResponse();

        res.setAcceptedSubProtocol("test1.0");

        }


If I read the docs right it should respond back that the subprotocol is supported.  Instead I get a null pointer error.

[qtp1799939500-23] WARN org.eclipse.jetty.websocket.common.WebSocketSession - 

java.lang.NullPointerException

at org.eclipse.jetty.websocket.servlet.ServletUpgradeResponse.setAcceptedSubProtocol(ServletUpgradeResponse.java:240)

at com.ezdray.routes.WebsocketHandler.connected(WebsocketHandler.java:53)



Am I doing this right?
Reply all
Reply to author
Forward
0 new messages