Websockets extensions error

Hi all,

I’m trying to use Websockets with extensions but they are not working.

Could someone shed light on this problem?

The example code is very simple:

`

val headers_wss = Map(

“Accept-Encoding” → “gzip, deflate, sdch, br”,

“Accept-Language” → “es,en;q=0.8”,

“Pragma” → “no-cache”,

“Cache-Control” → “no-cache”,

“Connection” → “Upgrade”,

"Sec-WebSocket-Extensions" → “permessage-deflate; client_max_window_bits”, // if this header is included the following exception is raised

“Sec-WebSocket-Key” → “Soc5rel3sgoH5Ku2ZWcHjQ==”,

“Sec-WebSocket-Version” → “13”,

“Upgrade” ->“websocket”)

val scnWebsocketsSecure = scenario(“WebSockets Secure scenario”)

.exec(ws(“socket”)

.open(“wss://echo.websocket.org/?encoding=text”)

.headers(headers_wss)

.check(wsAwait.within(120).until(1).regex(".id."))

)

.exec(ws(“socket”).close)

setUp(scnWebsocketsSecure.inject(atOnceUsers(1)))

`

  • this code is not exacly the same code I’m testing.

Output:

08:37:21.288 [WARN ] o.a.n.h.WebSocketHandler - onError {}
io.netty.handler.codec.CorruptedFrameException: RSV != 0 and no extension negoti
ated, RSV:4
at io.netty.handler.codec.http.websocketx.WebSocket08FrameDecoder.protoc
olViolation(WebSocket08FrameDecoder.java:434)
at io.netty.handler.codec.http.websocketx.WebSocket08FrameDecoder.decode
(WebSocket08FrameDecoder.java:156)
at io.netty.handler.codec.ReplayingDecoder.callDecode(ReplayingDecoder.j
ava:367)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessage
Decoder.java:248)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(Abst
ractChannelHandlerContext.java:342)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(Abst
ractChannelHandlerContext.java:328)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(Abstra
ctChannelHandlerContext.java:321)
at io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:1070)
at io.netty.handler.ssl.SslHandler.decode(SslHandler.java:904)
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageD
ecoder.java:411)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessage
Decoder.java:248)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(Abst
ractChannelHandlerContext.java:342)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(Abst
ractChannelHandlerContext.java:328)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(Abstra
ctChannelHandlerContext.java:321)
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(Defau
ltChannelPipeline.java:1280)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(Abst
ractChannelHandlerContext.java:342)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(Abst
ractChannelHandlerContext.java:328)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChanne
lPipeline.java:890)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(Abstra
ctNioByteChannel.java:131)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.jav
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEve
ntLoop.java:505)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.ja
va:419)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:391)
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThread
EventExecutor.java:112)
at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorato
r.run(DefaultThreadFactory.java:145)
at java.lang.Thread.run(Thread.java:745)
08:37:21.292 [ERROR] o.a.n.w.NettyWebSocket - WebSocketListener.onError crash
java.lang.NullPointerException: null
at io.gatling.http.action.async.ws.WsListener.onError(WsListener.scala:5
0)
at org.asynchttpclient.netty.ws.NettyWebSocket.onError(NettyWebSocket.ja
va:152)
at org.asynchttpclient.netty.handler.WebSocketHandler.handleException(We
bSocketHandler.java:213)
at org.asynchttpclient.netty.handler.AsyncHttpClientHandler.exceptionCau
ght(AsyncHttpClientHandler.java:212)
at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(
AbstractChannelHandlerContext.java:273)
at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(
AbstractChannelHandlerContext.java:252)
at io.netty.channel.AbstractChannelHandlerContext.fireExceptionCaught(Ab
stractChannelHandlerContext.java:244)
at io.netty.channel.ChannelInboundHandlerAdapter.exceptionCaught(Channel
InboundHandlerAdapter.java:131)
at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(
AbstractChannelHandlerContext.java:273)
at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(
AbstractChannelHandlerContext.java:252)
at io.netty.channel.AbstractChannelHandlerContext.fireExceptionCaught(Ab
stractChannelHandlerContext.java:244)
at io.netty.channel.ChannelInboundHandlerAdapter.exceptionCaught(Channel
InboundHandlerAdapter.java:131)
at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(
AbstractChannelHandlerContext.java:273)
at io.netty.channel.AbstractChannelHandlerContext.notifyHandlerException
(AbstractChannelHandlerContext.java:831)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(Abst
ractChannelHandlerContext.java:344)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(Abst
ractChannelHandlerContext.java:328)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(Abstra
ctChannelHandlerContext.java:321)
at io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:1070)
at io.netty.handler.ssl.SslHandler.decode(SslHandler.java:904)
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageD
ecoder.java:411)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessage
Decoder.java:248)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(Abst
ractChannelHandlerContext.java:342)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(Abst
ractChannelHandlerContext.java:328)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(Abstra
ctChannelHandlerContext.java:321)
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(Defau
ltChannelPipeline.java:1280)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(Abst
ractChannelHandlerContext.java:342)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(Abst
ractChannelHandlerContext.java:328)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChanne
lPipeline.java:890)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(Abstra
ctNioByteChannel.java:131)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.jav
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEve
ntLoop.java:505)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.ja
va:419)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:391)
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThread
EventExecutor.java:112)
at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorato
r.run(DefaultThreadFactory.java:145)
at java.lang.Thread.run(Thread.java:745)

Thx.

WebSocket extensions are not supported atm.
WebSocket extensions are a way to implement custom features on top of the standard protocol.

If we were to support them, it means we would have to provide you with hooks to implement your extension on the client side (here, I guess it would mean inflating the messages), as extensions are by essence purely proprietary stuff.

You’re the first one to ask for it, so we basically don’t have enough feedback atm.

Thx for your quick response :).

We are looking specifically for Websocket compression.

Thx for your quick response :).

We are looking specifically for Websocket compression.

I got that.
But some other people might have different needs.
For now we don't have sufficient feedback to make sure we come up with a
proper API that would match all many use cases as possible.
And you're the first one to ask for WebSocket Extensions support, so it's
not a priority for us.

As a consequence, I don't think we'll investigate this ourselves any time
soon, except through a consulting or sponsorship contract.
Then, contributions are of course welcome.

*Stéphane Landelle*
*GatlingCorp CEO*
slandelle@gatling.io

I have seen that netty libraries (netty-codec-http-4.0.37.Final.jar) used by Gatling 2.2.2 are not including websockets extension capabilities but in 4.1 is already included.

Yes, and we’ll upgrade at some point.
But still, WebSocket Extension won’t just magically works by upgrading Netty version.
You’d still need some hook so that you can implement in Gatling the client side of your extension.