- edited description
Websocket JSON response error
Hi Peter,
Requirement: I have to open a websocket connection and then I have to sent some JSON data in the next request and I have to get JSON data in the response.
Issue: I hope, I am able to make a connection as I was getting 101 response code with response headers in the Sampler Result. In the next request, I have sent some JSON data using Websocket Request-response sampler and I have got a response code as 200 and message as OK. But Instead of JSON response , Iam getting a response in Unicode format. I have attached the screenshot of each and every sampler result, request and response.
Queries: As I was getting the 200 response code , Can I conform my response is correct enough ? How Can I change the Unicode to JSON data ? Why am I getting the response in Unicode format instead of JSON data
Note: I have tried selecting the JSON, text , Binary, Browser and all the other views in View results tree.
Cheers Rajesh N
Comments (15)
-
reporter -
repo owner Hi,
Your requests and responses are ok (green = ok, it's that simple ;-)).
Seems your server is sending an incorrect character encoding (UTF-8 is mandated by the websocket specifiation).
To change the received data, you could for example use the beanshell postprocessor, see https://www.blazemeter.com/blog/how-use-beanshell-jmeters-favorite-built-component
Hth, Peter
-
reporter Thanks Peter. The response which I got in Unicode format , I have converted it to Binary and then to text, just to check whether we are getting any response. THe Text format displayed some kind of key format like "Websocket key" instead of JSON data. I am not familiar with Beanshell, Could you please some more information how to extract the JSON data.
Note: Actually it is live streaming data. Just as a Share market, We would view to fetch the live results
Cheers Rajesh N
-
repo owner The plugin shows the data exactly like how it got it from the server. So apparently, your server is sending data in a different format then you are expecting.
Do you have a regular client that can successfully communicate with the server? If so, you can capture the communication with WireShark and do the same for JMeter connecting with your server and compare the two to find out why it's behaving differently.
Hth, Peter
-
repo owner - changed status to closed
-
reporter - changed status to open
I have one more query regarding this
-
reporter Regarding the above one, I have tried explaining the same thing to the Developer . But the Developer still saying "**there is definitely something odd with jmeter as client of the web socket
Every other client tool we’ve used i.e. C#, python and javascript in browser has “just worked” against the streaming socket without any special modification or handling for this format/encoding**"
But my question over here is , When the response coming from the server to the browser, browser automatically decrypts data and displays it on the browser but JMeter doesn't do that , Please correct me If I am wrong .
So can we conclude that server is sending the response in a different format , but when it goes via through a browser, browser is decrypting it and displaying accordingly .
-
repo owner I Rajesh,
I'd like to help you to find out what't going on exactly, but i need more info. I vaguely remember the screenshot that was attached to this issue once, i don't remember it looked like encrypted data.....
Can you send more information? Specifically:
- jmeter log files, after you enabled debug logging for the plugin
- your jmeter test plan
- screenshots of the result.
You can email it to me so you don't have to share it with the world, my address is peter dot doornbosch at luminis dot eu.
Regards Peter
-
reporter - attached Websocket results.doc
- attached Websocket.jmx
Thanks Peter for looking into this issue again.
Please find the attached files
Note: There is no information about anything in logs apart from the thread progress. We will be not able to access gmail or any other email, so I have posted here only
Cheers Rajesh N
-
repo owner Hi Rajesh,
Thanks for the info; this helps. Apparently, your server is using the permessage-deflate WebSocket extension. This extension is not supported by this plugin. Sorry about that ;-(.
Regards Peter
-
repo owner Btw, you are requesting to use this extension with the "Sec-Websocket-Extensions" header. If you remove this one, you should get uncompressed data.
-
reporter It worked, by removing the above extension! Thank you so much Peter.
One more query- It is a live streaming data, but in JMeter I am getting only first set of data, how can get the complete streaming data in a request itself
Cheers Rajesh N
-
repo owner Read more frames. The websocket protocol is not stream based (as opposed to what lots of people think), but frame based. So, if you don't get all the data the server is sending, you need to read more frames. It could be the server is using continuation frames, see the paragraph titled "Fragmentation" in the readme (https://bitbucket.org/pjtr/jmeter-websocket-samplers/src/master/).
hth Peter
-
reporter - changed status to resolved
-
repo owner Nice. Thanks for the heads-up.
- Log in to comment