JMeter-WebSocketSampler icon indicating copy to clipboard operation
JMeter-WebSocketSampler copied to clipboard

replay not working

Open thgv opened this issue 10 years ago • 7 comments

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.

thgv avatar Feb 13 '14 00:02 thgv

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(.*)

fshutdown avatar Feb 13 '14 09:02 fshutdown

"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 [email protected] 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 avatar Feb 13 '14 14:02 thgv

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 [email protected] 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 [email protected] 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 avatar Feb 15 '14 20:02 thgv

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

  • You are using incorrect protocol; only ws and wss can be used which is equivalent of HTTP and HTTP respectively
  • There are problems with the server certificate;; use Ignore SSL certificate errors to get around this problem
  • You cannot connect directly without going through the proxy
  • The server is using WebSocket implementation not supported by this sampler; currently only RFC6455 is supported

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

fshutdown avatar Feb 17 '14 10:02 fshutdown

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.

thgv avatar Feb 20 '14 17:02 thgv

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

redguy666 avatar Jun 23 '15 15:06 redguy666

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

[Execution Flow]

  • Opening new connection
  • Using response message pattern ""
  • Using disconnect pattern ""
  • Waiting for the server connection for 20000 MILLISECONDS
  • WebSocket conection has been opened
  • Connection established
  • Received message #1 (7 bytes); matched response pattern
  • Waiting for messages for 800000 MILLISECONDS
  • Leaving streaming connection open

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

prutheel avatar Jan 22 '16 09:01 prutheel