I am getting error when script is executed in jmeter, because of signalr connection
I need to pass connectionToken and connectionData in the url as below.
"/Web/signalr/connect?transport=longPolling&clientProtocol=1.5&connectionToken=${connectionToken}&connectionData=${connectionData}"
i am able to capture ConnectionToken and passing that successfully. but, i am facing issue with connectionData, which looks like
[{"name":"alertshub"},{"name":"loggerhub"},{"name":"notificationhub"}]
How to capture and pass this.
Please find the screeshots
! enter image description here
! enter image description here
! enter image description here
! enter image description here
not able to capture below connection string
connectionData: [{"name":"alertshub"},{"name":"loggerhub"},{"name":"notificationhub"}]
get method sends above connectionData as
GET //abc.com/Web/signalr/negotiate?clientProtocol=1.5&connectionData=%5B%7B%22name%22%3A%22alertshub%22%7D%2C%7B%22name%22%3A%22loggerhub%22%7D%2C%7B%22name%22%3A%22notificationhub%22%7D%5D&_=1522754518635
and am getting the response connectionToken. i am able to extract connectionToken .
now, i need to send
GET //abc.com/Web/signalr/connect?transport=serverSentEvents&clientProtocol=1.5&tid=10&connectionToken=%27FcFUJytTeVDsNq4EM5iY59NrIlAO4EK0nU%2BP9fDasBFDTA%2B78kpLr05HaQoqstQouqyFMP2hShwh2eHdiG%2BCsRq7wNHs70BVSkjJiLIdyePfB3SmMCmeZeZyvd1xzfnc%27&connectionData=%255B%257B%2522name%2522%253A%2522alertshub%2522%257D%252C%257B%2522name%2522%253A%2522loggerhub%2522%257D%252C%257B%2522name%2522%253A%2522notificationhub%2522%257D%255D%26_%3D1522754518635
It has valid connectionToken(extracted) but not the connectionData.
Response is Unexpected character encountered while parsing value: %. Path '', line 0, position 0.
my question is how can i get this values, [{"name":"alertshub"},{"name":"loggerhub"},{"name":"notificationhub"}].
and next i need to post
POST //abc.com/Web/signalr/connect?transport=longPolling&clientProtocol=1.5&connectionToken=FcFUJytTeVDsNq4EM5iY59NrIlAO4EK0nU+P9fDasBFDTA+78kpLr05HaQoqstQouqyFMP2hShwh2eHdiG+CsRq7wNHs70BVSkjJiLIdyePfB3SmMCmeZeZyvd1xzfnc&connectionData=%5B%7B%22name%22%3A%22alertshub%22%7D%2C%7B%22name%22%3A%22loggerhub%22%7D%2C%7B%22name%22%3A%22notificationhub%22%7D%5D&_=1522754518635
as you can see here, it has valid connectionToken but not connectionData.
Response for this is : The ConnectionId is in the incorrect format.
BlazeMeter1
Blazemeter2
Blazemeter3
You need to use the same method as you have used for connection token.
It seems like your variable is not getting the required values. Are you using the same variables between two thread groups?
**-->Here request is encoded and connection data is also encoded.**
GET //abc.com/Web/signalr/negotiate?clientProtocol=1.5&connectionData=**%5B%7B%22name%22%3A%22alertshub%22%7D%2C%7B%22name%22%3A%22loggerhub%22%7D%2C%7B%22name%22%3A%22notificationhub%22%7D%5D**&_=1522754518635
and am getting the response connectionToken. i am able to extract connectionToken .
now, i need to send
**-->Here again encoded connection data is further encoded.**
GET //abc.com/Web/signalr/connect?transport=serverSentEvents&clientProtocol=1.5&tid=10&connectionToken=%27FcFUJytTeVDsNq4EM5iY59NrIlAO4EK0nU%2BP9fDasBFDTA%2B78kpLr05HaQoqstQouqyFMP2hShwh2eHdiG%2BCsRq7wNHs70BVSkjJiLIdyePfB3SmMCmeZeZyvd1xzfnc%27&connectionData=**%255B%257B%2522name%2522%253A%2522alertshub%2522%257D%252C%257B%2522name%2522%253A%2522loggerhub%2522%257D%252C%257B%2522name%2522%253A%2522notificationhub%2522%257D%255D%26**_%3D1522754518635
If I got it correct, then avoid encoding twice. In first and second screenshot you are encoding it twice.
If "connectionData" is fixed then try "User defined variables" or if it is available in some response then capture there using regular expression and use it further.
I hope you are not getting error during data extraction.
Related
I need to load test one Python api in below URL format:
//IP:PORT/Sub_Part/?where={"KEY1":"VALUE1","KEY2":"VALUE2","KEY3":"VALUE3"}
I tried to pass the key value pair through csv as well as directly in http request but getting error message.
java.net.URISyntaxException: Illegal character in query at index 47:
http://IP:PORT/Sub_Part/?where={"KEY1":"VALUE1","KEY2":"VALUE2","KEY3":"VALUE3"}
Here key and value are dummy data I have placed here for easy understanding.
Please help me with correct syntax for this URL.
Thanks in advance for all your help.
In REST APIs, JSON objects are typically sent (POST) or returned in the body of the request. They are not typically encoded as part of the URL.
For a GET request, you can either pass the information as segments in the url or as querystring parameters.
For more details refer here, How to send a GET request with a "/" in the query
As per HTML URL Encoding Reference:
URLs can only be sent over the Internet using the ASCII character-set.
so you need to define the request in JMeter's HTTP Request sampler as follows:
Pay attention to URL Encode? checkbox, it has to be ticked otherwise the parameter will be sent "as is"
Another option is using __urlencode() function like:
http://IP:PORT/Sub_Part/?where=${__urlencode({"KEY1":"VALUE1"\,"KEY2":"VALUE2"\,"KEY3":"VALUE3"})}
which will generate an encoded sequence which you could use in the URL path:
%7B%22KEY1%22%3A%22VALUE1%22%2C%22KEY2%22%3A%22VALUE2%22%2C%22KEY3%22%3A%22VALUE3%22%7D
as you can see, all non-ASCII characters where removed.
Check out Apache JMeter Functions - An Introduction to learn more about JMeter Functions concept.
Image . I decoded a token using JSR223 Post Processor and able to see correct decoded token in the log viewer using "log.info(vars.get(mystring));". Now I want to get that decoded data to send in another next request. So how I can do it?
I used following code to decode token and[enter image description here][2] print in the JMeter log viewer-
enter code here String a=vars.get("tokenid");
import encrypt.TokenUpdate;
TokenUpdate obj=new TokenUpdate();
String mystring=obj.enc(a);
log.info(mystringenter image description here);
log.info(vars.get(mystring));
decoded data is showing in the JMeter log viewer. So ho can I get that data and to send into another next request?
enter image description here
You can use vars.put and reference the variable in your next subsequent request.
Example below:
String a=vars.get("tokenid");
import encrypt.TokenUpdate;
TokenUpdate obj=new TokenUpdate();
String mystring=obj.enc(a);
log.info(vars.get(mystring));
vars.put("YourVariableName",mystring);
Now in your next subsequent sampler you can refer the variable like ${YourVariableName}
You can refer my other detailed answer on same topic here
I am recording Login in Jmeter. Password has '#'. Jmeter recorded exact string but when i run the same, '#' is converted to '%40ss' and login is getting failed(login is failing even if i pass parameters through csv file). But if we pass parameters through jmeter Body Data, Login is successful. I dont want to pass through Body Data, i want to send parameters through CSV file. How to achieve this. Please find the attachments
Recorded and Response
My expectation is that it is only a matter of representation, i.e. when I run similar request using a sniffer tool like Wireshark I can see # sign as a part of form data.
Most probably your problem lies somewhere else, i.e. you haven't correlated this __RequestVerificationToken or haven't added HTTP Cookie Manager.
When it comes to load testing ASP.NET web applications you cannot just record and replay your test, you need to perform correlation of dynamic parameters, check out ASP.NET Login Testing with JMeter article for more details.
Lakshmikanth, when you are passing any special character in parameters values then JMeter converts that character into percent-encoding for eg. '#' converts to '%40', '!' converts to '%21'.
To overcome this issue you can pass your password as it is [say P#ssword] in the .csv file but in your request you need to uncheck the encode checkbox corresponding to your password parameter.
I am using Jmeter to load test with 100 users
This is a REST Call using GET
As part of my request i am sending 3 parameters
ordersplitjson
customer_id
homedelivery
The ordersplitjson parameter is a JSON Value (somewhat big)
This is the request , captured from the browser and the same works when pasted in the browser directly
http:/localhost:8080/OMS/oms1/orderinsertservice?ordersplitjson={"highPriceVendor":"VC4%20Raj","vendors":{"T1":[{"item_ids_":"194","contact_phone_no_":"9876543210","name":"VC4%20Raj","contact_address":"Kukatpally,%20Hyderabad","leaf":[{"contact_phone_no":"9876543210","SurCharges":"50","vendorname":"VC4%20Raj","count":"0","contact_email":"rajk#gmail.com","discount_div":"10Rs","itemid":"194","strikeprice_cutoff":"110","name":"Popcorn%20Regular%20%20%20300%20ML%20Fountain%20Apple","quantity":"1","contact_address":"Kukatpally,%20Hyderabad","date_time":"18:10:19","email_id":"raj#hmail.com","toppings":[],"screen":"SCR-3","seat_num":"D12","customer_name":"Ganesh","image":"images/icon-print.png","contact_person":"Kiran","item_description":"Item%20description","vendor_id":"9","crusts":[],"Vat":"70","customer_mobil":"9090987878","price":"100","mobile_number":"1234567898","ServicesCharges":"50","orderid":"14101519"}],"vendor_id":"9"}]}}&customer_id=22&homedelivery=Yes
But under Jmeter , i am always getting error
java.net.URISyntaxException: Illegal character in query at index 64:
These are my screen shots
Could anybody please help me how to resolve this ??
Your HTTP Sampler Settings & HTTP Header settings should be same as the attached pictures below
Hope this will help.
My script get an authenticity token from first page, then pass it to the second page I got this error when running the test:
{"errors":{"error:":["ActionController::InvalidAuthenticityToken"]}}
I checked the token variable, apparently the string such as /, = has been encoded into %2F and %3D etc..
On my second page's HTTP request window, I have NOT selected "encoded" for token variable defined in the "Send parameters with the request" section.
Apparently the problem is I did not asked for encoded variable, JMeter just encode it. Is it a known bug or I should do something to decode it or is there a work around on this issue?
Did you pass token in POST data?
I'v faced the same problem and just pass body data as work around, to do it you need:
Select you HTTP sampler
Switch from "Parameter" to "Body Data" tab (you have to delete all parameters to do it)
Write body data (variable substitution works)
Body data example:
username=Some_name&token=AbRaCaDaBrA
NB, if something need to be encoded, you'll have to do it manually.