How can I configure subprotocol for Netty io?

2019-09-10 06:08发布

问题:

I am using websockets with Play framework. When I try to set value to the HTTP header Sec-WebSocket-Protocol, e.g. "ocpp1.6" then I get the following exception:

[error] p.nettyException - Exception caught in Netty
org.jboss.netty.handler.codec.http.websocketx.WebSocketHandshakeException: Requested subprotocol(s) not supported: ocpp1.6

I can see that the error occurs because the constructor's "subprotocols" parameter in org.jboss.netty.handler.codec.http.websocketx.WebSocketServerHandshakerFactory is null.

Therefore how can I change this value and is it the only reason which causes the error?

Thanks, -Louise

回答1:

It seems it is a known bug that the Play framework did not support subprotocols, which should be fixed by version 2.2.1:

https://github.com/playframework/playframework/pull/1722