fshutdown / JMeter-WebSocketSampler

JMeter - WebSocket Sampler
Apache License 2.0
312 stars 191 forks source link

replay not working #10

Open thgv opened 10 years ago

thgv commented 10 years ago

Hi I tried to use this plugin again after failing to find another testing tool to record and replay websocket communications.

I went through the user steps of my test scenario manually using chrome dev-tools and compared the requests with what I had in the recorded jmeter script. The recorded script contained one socket.io request (a http request) but did not contain the second socket.io request that used the websocket protocol. The first socket io request (the http request) establishes a http handshake with the server and if successful returns a websocket sessionid in its response. The second socket io request opens a websocket connection using this websocket session id.

  1. http://hostxxx:8085/socket.io/1/?t=1392216702519 Response:xDK157IQk4_xXCQvaa08:60:60:websocket,htmlfile,xhr-polling,jsonp-polling 2.ws://hostxxx:8085/socket.io/1/websocket/xDK157IQk4_xXCQvaa08

To extract the websocket session id, I added a post processor (Regex extractor) to the first socket io request in the recorded script and used the regex pattern (^.*): and stored it in the variable websocketSessionId Template $0$ Match:1 I added a websocketSampler in this recorded script and then set webserver and port and added the path as /socket.io/1/websocket/$websocketSessionId$ On replay the first socket io was successful. websocket session id was returned in the response but the second one (the websocketsampler) failed. Both request and response were empty for this request in View Results Tree. What could I have missed ? Not sure if I have used the regex extractor incorrectly or missed setting something in the websocketsampler.

fshutdown commented 10 years ago

The HTTP to WebSocket protocol upgrade is a part of the sampler code so I'm not sure whether you need both in your scrtipt.

WebSocket sampler will return response with message index marker like this:

[Message 1]
MySessionIdNumberIsHere

I would imagine that you RexEx pattern (^.*) would match only the first line (i.e. [Message 1]) The following expression will be better siuted:

\[Message 1\]\s(.*)
thgv commented 10 years ago

"The HTTP to WebSocket protocol upgrade is a part of the sampler code so I'm not sure whether you need both in your script"

In the line above, are you referring to Http request sampler and websocket sampler when you say both?

I just replayed the jmeter test script and this is what I found in the response tab of view Results Tree for the first socket io request  (http://host:8085/socket.io/1/%3Et=1392300599780: 6WIKeXU5vvqqyVYcaa1E:60:60:websocket,htmlfile,xhr-polling,jsonp-polling

I did not see the message index marker... I tried the expression you suggested but same result as before. Request failed and view Results Tree shows nothing in request and response tabs.   I saw this in the Sampler results:

Thread Name: WebSocketTest3 1-1 Sample Start: 2014-02-13 09:10:00 EST Load time: 25053 Latency: 0 Size in bytes: 0 Headers size in bytes: 0 Body size in bytes: 0 Sample Count: 1 Error Count: 0 Response code: 200 Response message: [Execution Flow]  - Opening new connection  - Using response message pattern ""  - Using disconnect pattern ""  - Waiting for the server connection for 5000 MILLISECONDS  - Cannot connect to the remote server  - Waiting for messages for 20000 MILLISECONDS  - WebSocket conection closed by the client [Variables]  - Message count: 0

Not sure if there is anything helpful there... Thanks.

On Thursday, February 13, 2014 4:54 AM, Maciej Zaleski notifications@github.com wrote:

The HTTP to WebSocket protocol upgrade is a part of the sampler code so I'm not sure whether you need both in your scrtipt. WebSocket sampler will return response with message index marker like this: [Message 1] MySessionIdNumberIsHere
I would imagine that you RexEx pattern (^.) would match only the first line (i.e. [Message 1]) The following expression will be better siuted: [Message 1]\s(.)
— Reply to this email directly or view it on GitHub.

thgv commented 10 years ago

Hi, I added HTTP cookie manager in the thread group so cookie handling is automatic for all http requests. However would this work for the websocket sampler request? If it does not, how can I handle it manually for this request? Thanks.

On Thursday, February 13, 2014 9:33 AM, Thara Vadakkeveedu tharagv@yahoo.com wrote:

"The HTTP to WebSocket protocol upgrade is a part of the sampler code so I'm not sure whether you need both in your script"

In the line above, are you referring to Http request sampler and websocket sampler when you say both?

I just replayed the jmeter test script and this is what I found in the response tab of view Results Tree for the first socket io request  (http://host:8085/socket.io/1/%3Et=1392300599780: 6WIKeXU5vvqqyVYcaa1E:60:60:websocket,htmlfile,xhr-polling,jsonp-polling

I did not see the message index marker... I tried the expression you suggested but same result as before. Request failed and view Results Tree shows nothing in request and response tabs.   I saw this in the Sampler results:

Thread Name: WebSocketTest3 1-1 Sample Start: 2014-02-13 09:10:00 EST Load time: 25053 Latency: 0 Size in bytes: 0 Headers size in bytes: 0 Body size in bytes: 0 Sample Count: 1 Error Count: 0 Response code: 200 Response message: [Execution Flow]  - Opening new connection  - Using response message pattern ""  - Using disconnect pattern ""  - Waiting for the server connection for 5000 MILLISECONDS  - Cannot connect to the remote server  - Waiting for messages for 20000 MILLISECONDS  - WebSocket conection closed by the client

[Variables]  - Message count: 0

Not sure if there is anything helpful there... Thanks.

On Thursday, February 13, 2014 4:54 AM, Maciej Zaleski notifications@github.com wrote:

The HTTP to WebSocket protocol upgrade is a part of the sampler code so I'm not sure whether you need both in your scrtipt. WebSocket sampler will return response with message index marker like this: [Message 1] MySessionIdNumberIsHere
I would imagine that you RexEx pattern (^.) would match only the first line (i.e. [Message 1]) The following expression will be better siuted: [Message 1]\s(.)
— Reply to this email directly or view it on GitHub.

fshutdown commented 10 years ago

By the look of things the sampler did not manage to establish a WebSocket connection with the server. There could be few things here:

Rerarding cookies you will have to handle this manually for now. You can add header called Cookie with cookie values in the WebSocket sampler

Example:

Cookie: name=value; name2=value2
thgv commented 10 years ago

Thank you. I am using ws and not wss. This is the protocol to use. I can connect directly without going through the proxy. Not sure what websocket implementation my server is using. I am looking into it. I tried to handle the cookie manually,debug sampler shows the variable carrying the right value, but I get an error when replaying this socket.io request. In view results tree, request tab is empty and response tab shows 7:::1+0 Thanks.

redguy666 commented 9 years ago

We had similar issue and solved it upgrading Java VM 1.7 -> 1.8

prutheel commented 8 years ago

I am getting same response "7:::1+0" even After changing the Protocol to WSS and Upgrading to JAVA 1.8

[Execution Flow]

Here is my Sampler configuration:

Path: socket.io/1/websocket/${socid} Connection ID: ${socid} Request DATA: 5:::{"name":"join","args":["Ag_10","${GUID}"]} Response Pattern: (Blank) Close Connection Pattern: (Blank)

What could I have missed? If anyont know Please do let me know...I am new at this Websocket thing so looking for help