Intermittent Response code 400 Bad Request error message on WebSocket Upgrade
Hi Peter,
Many thanks for all the work you have put into the WebSocket Sampler over the years. I for one appreciate it :-)
I'm having a problem where the Open WebSocket sampler works intermittently for me. Around 20% of times the upgrade to WebSocket works fine but the remaining 80% of the time I get Response code 400 Bad Request error.
OpenWebSocketSampler: Http upgrade error in sampler 'WebSocket Open Connection' eu.luminis.websocket.HttpUpgradeException: Got unexpected status 400
The odd thing is that this is with the same script - with no modifications made between iterations. I don't believe its a backend server issue as we have a Neoload WebSocket script working correctly in the same test environment. Its must be client related but as stated above I'm not changing the script and it its working only intermittently.
I've attached screenshots and output logs of the successful & failed results.
Any help appreciated.
Thanks
Ajaz
Comments (3)
-
repo owner -
repo owner - marked as task
-
repo owner - changed status to wontfix
- Log in to comment
Hi,
Thanks for your positive feedback.
In general, when one encounters a 400, i always advise to check the server logs, as the server knows why the request was rejected, so the server can tell the real cause of the problem. All other attempts to find the root cause is pure guessing.
Now, let’s see what you are guessing :
W.r.t. your question: i wonder what makes you think the sampler is wrong? Let’s analyse the http request as logged in the provide log files (i removed the clutter):
So your testplan provides:
The plugin provides:
Sec-WebSocket-Key
Now the server is rejecting you request without telling why (there could be a reason on the status line, but there isn’t ).
The only requirement for the Sec-WebSocket-Key (see https://datatracker.ietf.org/doc/html/rfc6455#section-4.1 is that it is a 16 byte random value that is base64 encoded. Decoding
jQmV5aJPWL4aM3MUx+kOfA==
: 8D 09 95 E5 A2 4F 58 BE 1A 33 73 14 C7 E9 0E 7C. 16 bytes.What else could be wrong? Non-printable characters in the request I guess; we can’t tell unless you capture communication with WireShark.
What else? Probably (guessing!), either the URL or the value of a cookie is wrong.
Hth
Peter