WebSocket handshake overriding header

Hello, I’ve migration of my project to Gatling 3.0, but faced with the problem while opening a websocket in code like this:


class ConnectSimulation extends Simulation {
  val wsUrl = "ws://localhost:8008"
  val wsConfig: HttpProtocolBuilder = http.wsBaseUrl(wsUrl)

  val scn: ScenarioBuilder = scenario("Connection test").repeat(1) {
    exec(ws("Open Socket").connect(wsUrl))



When gatling sends HTTP handshake request for opening a websocket, server refuses the connection with error code 400.


GET / HTTP/1.1
accept: */*
origin: http://localhost:8008
upgrade: websocket
connection: upgrade
sec-websocket-key: cV1C+6FK0GQslEA+0G4vmA==
host: localhost:8008
sec-websocket-origin: http://localhost:8008
sec-websocket-version: 13

HTTP/1.1 400 Bad Request
Server: fasthttp
Content-Type: text/plain; charset=utf-8
Content-Length: 64


The same code like in program above for Gatling version 2.3 returns:

Request DefaultFullHttpRequest(decodeResult: success, version: HTTP/1.1, content: EmptyByteBufBE)
GET / HTTP/1.1
Upgrade: WebSocket
Connection: Upgrade
Sec-WebSocket-Key: mqV2A6yTtYMbFuc5CwdPuA==
Sec-WebSocket-Version: 13
Origin: http://localhost:8008
Host: localhost:8008
Accept: /

Response DefaultHttpResponse(decodeResult: success, version: HTTP/1.1)
HTTP/1.1 101 SwitchingProtocols
Server: fasthttp
Upgrade: websocket
Connection: Upgrade
Sec-Websocket-Accept: n58uYR0L4TFCdEF2Xta+YZf+bUE=

The main difference in requests headers is that first letter of сonnection header value is capital in Gatling version 2.3 while in gatling 3.0 it’s lowercase.

That is the main problem. Server which I’m trying to connect accepts request only if connection header value starts with capital letter: “Upgrade”
I don’t have access to the server and can’t make any changes on server side.

Is there any ways to override connection header value to make that first letter capitalized?
Or may be there are some workarounds that allows me to collect a simple HTTP request by myself and after that work with that websocket session?

The issue is most likely https://github.com/gatling/gatling/issues/3606

  • HTTP header names are case insensitive. That’s from the HTTP specs and not debatable. If your server implementation (fastparse in your case) handles some header names in a case sensitive fashion, that’s a bug on their side and you should report to them.
  • HTTP header values are case sensitive and the proper case is “websocket” and “Upgrade”, according to https://tools.ietf.org/html/rfc6455. There’s indeed a bug in Netty that sends “upgrade” in minor case instead.

Thanks for reporting!

Actually, I stand corrected, and the RFC is pretty explicit and those values MUST be handled in a case insensitive fashion.
I advice that you send a notice to your developers so that hey open an issue against the software they use (fasthttp).


Thanks a lot for your replying!

I will report an issue to fasthttp developrs.
Hope, they will react as quickly as you :slight_smile:

I guess so, fix should be pretty straightforward :slight_smile: