0

I have to do the performance testing of an application which has web socket connection. For this, I used Web socket sampler in Jmeter.

I need to extract an item named "Connection Token" from the response of an HTTP request and pass it with next HTTP requests. I have extracted that using Regular Expression Extractor and passed that as a parameter in Web Socket Sampler.

Please see the below image

enter image description here

My issue is : When I pass the above parameter with other requests, I'm getting an error that "Connection id is in incorrect format".

Please see the below images

enter image description here

enter image description here

Can anybody help in fixing this problem?

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

Adil B
  • 14,635
  • 11
  • 60
  • 78
Amrutha
  • 301
  • 1
  • 7
  • 20
  • can you please show us request/connectionId (/180 or /177 request) in Request tab from View Results Tree? Is the value being replaced as expected? Also, share your Regular Expression Extractor screenshot – Naveen Kumar R B Nov 02 '16 at 07:25
  • Yes the value is being replaced as expected. Will share the screen shot – Amrutha Nov 02 '16 at 08:48
  • Screenshot of the Request tab and Regular expression extractor is added in the question – Amrutha Nov 02 '16 at 08:55

1 Answers1

0

The problem could be how you are sending + in your request. Server may be expecting +, but you are sending %20

In the image: enter image description here

I can observe that at the end of connectionToken value, %20 is added. Please check how the value should be sent i.e., with encoding or without encoding.

If you want to send +, then try as follows:

${__urlencode(${session})}

References:

  1. URL encode variable in Jmeter
  2. URL encoding the space character: + or %20?

please try and let me know

Community
  • 1
  • 1
Naveen Kumar R B
  • 6,248
  • 5
  • 32
  • 65
  • I have tried ${__urlencode(${session})}. Now '+' is send with the request. But the same error is shown again. Will share the screen – Amrutha Nov 02 '16 at 09:30
  • Screenshot is added with the question – Amrutha Nov 02 '16 at 09:33
  • In the latest screen shot, i can observe that all special characters are encoded like '/' for '%2F', 'space' for '%20', '+' for '%2B' because of using __urlencode function. As it not working, then we should try not to encode and remove '%20' (space in previous request) and try. Are you sure "space" (%20) is part of your connection token? – Naveen Kumar R B Nov 02 '16 at 09:40
  • refer the following url for "URL Encoded Characters", http://www.degraeve.com/reference/urlencoding.php – Naveen Kumar R B Nov 02 '16 at 09:41
  • why did you change (\177) request from GET to POST? – Naveen Kumar R B Nov 02 '16 at 09:46
  • \177, If it is GET request, use ${__urlencode()}. if it is POST, then in Parameters tab, add the key-value pairs in Parameters tab of HTTP sampler (instead of Path field) and select "Encode?" checkbox – Naveen Kumar R B Nov 02 '16 at 09:49
  • Space is not a part of connection token. How can i remove that..? – Amrutha Nov 02 '16 at 09:58
  • It is a GET request and i have used ${__urlencode()}. But same error exists. And space is not a part of connection token. How can i remove that..? – Amrutha Nov 02 '16 at 10:05
  • while capturing itself (by keeping regular expression more restrictive on the right boundary) or you can use BeanShell post-processor to process the string to remove extra space using trim method (Java String method). I would suggest use the first option i.e., capture only the value required. – Naveen Kumar R B Nov 02 '16 at 10:07
  • I need to extract Connection token form this :{"Url":"/signalr","ConnectionToken":"beHtBBfhfUULaMWwFjwGb2AlZstnlQkcjM/DLfPnRXRNM/H3rCxXc14LrZhaoR3qFGibi759ci8TsacCh0s5lL9xhPTibvmxSBHrspxy3b6/t8b38TUN7IzoLfpoEXWs","ConnectionId":"17922e47-6aff-4f59-b325-d2e8ebf12919","KeepAliveTimeout":20.0,"DisconnectTimeout":30.0,"ConnectionTimeout":110.0,"TryWebSockets":true,"ProtocolVersion":"1.5","TransportConnectTimeout":5.0,"LongPollDelay":0.0} – Amrutha Nov 02 '16 at 10:15
  • And i used the regular expression : signalr","ConnectionToken":"([0-9A-Za-z+\/]+)","ConnectionId":" Can you please tell what change i have to make in Regular expression to avoid space – Amrutha Nov 02 '16 at 10:17
  • can you add screenshot of the Debug sampler from View Results Tree? We can check the matches. – Naveen Kumar R B Nov 02 '16 at 10:18
  • Sure. Screenshot is added with question – Amrutha Nov 02 '16 at 10:22
  • not able to see the end point of session in the Debug Sampler results? can you scroll to right and take screenshot? check whether space is captured? – Naveen Kumar R B Nov 02 '16 at 10:25
  • Added a new screenshot – Amrutha Nov 02 '16 at 10:33
  • check your Path field whether you added any addiitonal space after ${session} – Naveen Kumar R B Nov 02 '16 at 10:35
  • I am not sure now, what the problem is all about – Naveen Kumar R B Nov 02 '16 at 10:35
  • No space is added after ${session} in Path field – Amrutha Nov 02 '16 at 10:40
  • so, the last 4 chars are "RACM" in the latest screenshot, but sent as "RACM+" in subsequent requests??? – Naveen Kumar R B Nov 02 '16 at 10:43
  • Yes... It is sent as "RACM+" in subsequent requests – Amrutha Nov 02 '16 at 10:51
  • It is ONLY possible if regular expression extractor capturing it Or you added space after ${session} in the path. I suspect it is from Regular expression extractor only. copy the value in session (Debug Sampler, View Results Tree) into Notepad++ and see whether there is any space included – Naveen Kumar R B Nov 02 '16 at 10:55
  • I think there is a space in the value that is extracted. How can i remove that..? – Amrutha Nov 03 '16 at 04:08
  • Hi, i have removed space from the end of the connection token using ${__javaScript("${session}".substring(0\,128),)}. But still the same error is shown : "ConnectionId is in incorrect format. Screenshot is added with the question – Amrutha Nov 03 '16 at 05:22
  • capture the request using proxy again, and check how the connectionToken is send in /177 request and try to exactly mimic that in the Path field (i.e., whether complete and correct token is captured or not, whether encoding is required or not). Once you record the script, share the screenshot of /177 request before modifying it. The thumb rule is you simulate the request (during replay) exactly as generated by the browser (during recording). – Naveen Kumar R B Nov 03 '16 at 06:00
  • Hi, I have fixed this problem by removing space from Connection Token in all the subsequesnt requests using ${__javaScript("${session}".substring(0\,128),)}. Now i'm facing another issue. Screenshot is added with the question – Amrutha Nov 03 '16 at 08:56
  • can you share the screenshots for /176 HTTP sampler request, and /176 Request tab in View Results Tree? – Naveen Kumar R B Nov 03 '16 at 09:17
  • Sure. Screenshots are added with question – Amrutha Nov 03 '16 at 09:41
  • please also share the HTTP sampler request screenshot of /176. I want to check how you are building the request – Naveen Kumar R B Nov 03 '16 at 09:45
  • Added. Please check. – Amrutha Nov 03 '16 at 09:50
  • Uncheck "encode?" for connectionToken (don't encode). may be for this request, encoding is not required. (I am guessing it as the error shows that, Unexpected character % in the path). try and let me know. As I said, your reference point for building the correct request is the request which is recorded during recording. – Naveen Kumar R B Nov 03 '16 at 09:52
  • Okay. Will check and let you know. – Amrutha Nov 03 '16 at 10:04
  • One common solution for all problems is that, compare the requests i.e., being sent during replay and the request i.e., recorded. find the differences. – Naveen Kumar R B Nov 03 '16 at 10:07
  • The only difference is in the value for connection token. – Amrutha Nov 03 '16 at 10:13
  • Now i have done one thing in the last screen shot Connection data was also encoded. Now i unchecked it and run the test. It got stuck in the middle. I will add a screen shot – Amrutha Nov 03 '16 at 10:16
  • As per the recorded request, do we need to encode the connectionToken & connectionData? If yes, then you must do encoding and try to resolve the problem. If not, then it is may be switching b/w the protocols i.e, web socket and HTTP (you can observe the switch b/w the protocols in headers of the previous requests). Disable requests related to web socket and replay. – Naveen Kumar R B Nov 03 '16 at 10:34
  • As per the recorded request, we need not encode connectionToken & connectionData. But if connectionToken is not encoded then it will throw the error "ConnectionId is in incorrect format" – Amrutha Nov 03 '16 at 11:35
  • better contact the dev team and ask what does it mean? coordinate with them. send the request and ask dev team to monitor at server logs and check whats wrong with the connectionId i.e., sent – Naveen Kumar R B Nov 03 '16 at 11:38
  • Hi, there was a small mistake in what i told last day. We need to encode the Connection Token before passing it through subsequent requests. So i encoded it. When the test is run, it got stuck in middle. Nothing happens even after waiting for some time – Amrutha Nov 08 '16 at 09:46
  • Disable WebSocket sampler (all) and try. because when you use WebSocket request, you have to switch b/w protocols. – Naveen Kumar R B Nov 08 '16 at 10:05
  • Okay. Will try and let you know – Amrutha Nov 08 '16 at 10:10
  • Disabled the WebSocket sampler and tried. But still the same issue. Please see the screenshot added with question – Amrutha Nov 08 '16 at 10:14
  • I am not sure what the reason is (guess it is related to switching b/w protocols). try the following 1. launch the JMeter in debug mode and observe the logs (jmeter.bat -L DEBUG), you can refer the logs in Log icon. 2. Analyse the request/response using Browser (F12 -> Network tab). I guess it has sent /176 request, but waiting for the response where server did not respond. – Naveen Kumar R B Nov 08 '16 at 13:02
  • One doubt.. If i open jmeter using jmeter.bat -L DEBUG (ie; using command propmt) the UI of jmeter will not be opened up, right..? Then how can i click the Log icon and refer the logs..? – Amrutha Nov 09 '16 at 04:26
  • Hi... launched the jmeter using jmeter.bat -L DEBUG. Will check the log. Thanks – Amrutha Nov 09 '16 at 05:01
  • checked. but images are deleted from the question during analysis. please only share the last 2 screenshots of the log where execution is got struck – Naveen Kumar R B Nov 09 '16 at 06:19
  • create a chatroom in stackoverflow. please join here http://chat.stackoverflow.com/rooms/127685/jmeter-websocket. It is becoming difficult to discuss the problem in comments – Naveen Kumar R B Nov 09 '16 at 06:30
  • As you said "Analyse the request/response using Browser (F12 -> Network tab). I guess it has sent /176 request, but waiting for the response where server did not respond", i have analyzed it. While running the application in a browser, we are getting the response for every request and the application works fine – Amrutha Nov 09 '16 at 06:41
  • can you join the chat here http://chat.stackoverflow.com/rooms/127685/jmeter-websocket – Naveen Kumar R B Nov 09 '16 at 06:42
  • Hi, i cannot use chatroom, since i dont have 20 reputation – Amrutha Nov 09 '16 at 06:43
  • still not possible to use chatroom. Added screensot – Amrutha Nov 09 '16 at 06:53
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/127688/discussion-between-naveen-and-amrutha). – Naveen Kumar R B Nov 09 '16 at 06:54