JMeter-WebSocketSampler
JMeter-WebSocketSampler copied to clipboard
Added support for headers and cookies in WebSocket upgrade request
Hi Vadim,
Appreciate for adding cookies and headers stuff into client upgrade request.
Could you please tell me who surrounds cookies send in upgrade request with quotes? Have you faced with similar problem and what did you do?
Thanks.
Nope - I have not seen this happening. From what I can tell, the HTTP Cookie Manager faithfully preserves the cookie value as it was sent in the server response. The CookieStore created by the code I've just added does not add quotes either. The server I am using does not received the cookie values quoted. The only thing I can think of is that the server itself sends the values quoted to be begin with. You can try to debug this using something like WireShark.
Found the problem. Java API 1.8, I'm using set, HttpCookie version to 1 by default - this is done to make it compatibile with RFC 2965/2109. In this version java api surrounds cookie value with quotes.
Fortunately, you used exactly HttpCookie object inside modified WebSocketSampler code so I'm just simly calling the method setVersion(0) every time I add cookie to cookieStore.
It took me a day to find it out but now ... I'm happy.
Thanks again for this improvement!
P.S. Do not want to commit code here as it may affect someone in other environemnts. Just in case add this code rows here:
HttpCookie tmpCookie = new HttpCookie(cookieManager.get(i).getName(),cookieManager.get(i).getValue());
tmpCookie.setVersion(0);
cookieStore.add(
new URI(null,
cookieManager.get(i).getDomain(),
cookieManager.get(i).getPath(),
null),tmpCookie
);
I've incorporated your cookie version suggestion using the existing version data maintained by CookieManager.
hi, tradingscreen! Could you supply a jar file with headers support? thanks a lot.
Hello. It'd be great if you supply a jar file with headers support. Thanks
Hi. I’ve added ZIPped JAR file at the root of source tree.
From: paldaz [mailto:[email protected]] Sent: Thursday, February 12, 2015 9:09 AM To: maciejzaleski/JMeter-WebSocketSampler Cc: TSNext Subject: Re: [JMeter-WebSocketSampler] Added support for headers and cookies in WebSocket upgrade request (#22)
Hello. It'd be great if you supply a jar file with headers support. Thanks
— Reply to this email directly or view it on GitHubhttps://github.com/maciejzaleski/JMeter-WebSocketSampler/pull/22#issuecomment-74075871.
Thanks tradingscreen :+1:
Hello, Do you have any examples explaining how to use your code to add headers to a websocket sampler? Thanks
Websocket sampler does not manage headers (nor cookies) itself. Websocket sampler just obeys the same rules that any sampler should and picks up headers from the standard JMeter "HTTP Header Manager" and cookies from "HTTP Cookie Manager". Take a look at JMeter manual to see how these work.
thank you for the answer
@tradingscreen I am able to open web socket connection using this sampler. my next requirement is to send different JSON message on every second.
is it possible to send these message using this sampler? if yes than how?
Thanks in advance.
You can have a "loop" with a "pause" set to 1s and the websocket sampler that has the JSON in "Request data" field. You can use regular expression extractor to pull whatever values you may need from the server messages coming over the websocket.
I would also recommend looking at mkaczara/JMeter-WebSocketSampler repository as it pulled in the fixes from this repository as well as added a bunch of other improvements
@tradingscreen Thank you Sir. It is working fine.
hi, tradingscreen! Could you supply a jar file with headers support? thanks in adwance
Please, take a look at the Feb 13 and Aug 14 comments.
@tradingscreen
I am working on Signalr, This is my project requirement hence downloaded websocket version websocket-9.1.1.v20140108, I dont have a good knowledge on JAVA. I am using maciejzaleski websocket sampler in JMeter First time. After a lot of r&d I success to communicate with Signalr via your Websocket sampler. Now my project build got upgraded & they are passing a Cookie Data: .ASPXAUTH=0AE3BF3FE55AAADC5FFEAFE1120F1E45B84AC2C7D227BC8F8E1585E74D14852798F5D27B688D4AFC2C1E494263077178ECBAFC126F4D7D258A21F258779B4B9749BE9D819C51FCBE7D116691F2020FC8EABE622396AA80201872F5C671009EBB in each (Http & WS) request. Via Jmeter cookie manager in each http request cookie handled correctly & requests were passing but my Websocket requests were failing because its not passing the Cookie data.
I have gone through all above comments. As I told I can rate myself 1 outof 10 in JVAV.
Could you please let me know or send me the required websocket JAR file which handles cookies @ [email protected].
Or any guide line also help me...Please
Thanks In Advance.
I'm sorry to reply to you so long ago,Because I saw your mail today.You need the websocket JAR file inside the attachment,about http request cookie I Suggest you added in front of the thread group,Do not know can help you solve your problem.
good luck!
From: ChittaRanjan1981 Date: 2017-02-13 13:14 To: maciejzaleski/JMeter-WebSocketSampler CC: angelqing; Comment Subject: Re: [maciejzaleski/JMeter-WebSocketSampler] Added support for headers and cookies in WebSocket upgrade request (#22) @tradingscreen I am working on Signalr, This is my project requirement hence downloaded websocket version websocket-9.1.1.v20140108, I dont have a good knowledge on JAVA. I am using maciejzaleski websocket sampler in JMeter First time. After a lot of r&d I success to communicate with Signalr via your Websocket sampler. Now my project build got upgraded & they are passing a Cookie Data: .ASPXAUTH=0AE3BF3FE55AAADC5FFEAFE1120F1E45B84AC2C7D227BC8F8E1585E74D14852798F5D27B688D4AFC2C1E494263077178ECBAFC126F4D7D258A21F258779B4B9749BE9D819C51FCBE7D116691F2020FC8EABE622396AA80201872F5C671009EBB in each (Http & WS) request. Via Jmeter cookie manager in each http request cookie handled correctly & requests were passing but my Websocket requests were failing because its not passing the Cookie data. I have gone through all above comments. As I told I can rate myself 1 outof 10 in JVAV. Could you please let me know or send me the required websocket JAR file which handles cookies @ [email protected]. Or any guide line also help me...Please Thanks In Advance. — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.
Thanks for your reply.. Attached Jar is not working for my signalr request. I already added HTTP cookie manager & Header manger with the test plan. Could you please let me know is there any extra configuration required.
In view result tree I can observe no cookie is passing.
You have a release on Feb 13 & In Oct in GIT. The latest release on October don't have any jar why? Feb 13 jar is not working for me with SignalR..
Don't have any jar file attached along with this mail. Please Pass me the jar which support websocket cookie.
On 2/15/2017 7:07 AM, angelqing wrote:
I'm sorry to reply to you so long ago,Because I saw your mail today.You need the websocket JAR file inside the attachment,about http request cookie I Suggest you added in front of the thread group,Do not know can help you solve your problem.
good luck!
From: ChittaRanjan1981 Date: 2017-02-13 13:14 To: maciejzaleski/JMeter-WebSocketSampler CC: angelqing; Comment Subject: Re: [maciejzaleski/JMeter-WebSocketSampler] Added support for headers and cookies in WebSocket upgrade request (#22) @tradingscreen I am working on Signalr, This is my project requirement hence downloaded websocket version websocket-9.1.1.v20140108, I dont have a good knowledge on JAVA. I am using maciejzaleski websocket sampler in JMeter First time. After a lot of r&d I success to communicate with Signalr via your Websocket sampler. Now my project build got upgraded & they are passing a Cookie Data: .ASPXAUTH=0AE3BF3FE55AAADC5FFEAFE1120F1E45B84AC2C7D227BC8F8E1585E74D14852798F5D27B688D4AFC2C1E494263077178ECBAFC126F4D7D258A21F258779B4B9749BE9D819C51FCBE7D116691F2020FC8EABE622396AA80201872F5C671009EBB in each (Http & WS) request. Via Jmeter cookie manager in each http request cookie handled correctly & requests were passing but my Websocket requests were failing because its not passing the Cookie data. I have gone through all above comments. As I told I can rate myself 1 outof 10 in JVAV. Could you please let me know or send me the required websocket JAR file which handles cookies @ [email protected]. Or any guide line also help me...Please Thanks In Advance. — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/maciejzaleski/JMeter-WebSocketSampler/pull/22#issuecomment-279892493, or mute the thread https://github.com/notifications/unsubscribe-auth/AYisqNg1QaEJVKHWSDM7rHz1hybigg3iks5rclb1gaJpZM4ByXwO.
-- Warm Regards,
Chitta Ranjan Module Lead
Millennium City Information Technology Park, Tower II, Floor - Floor – 9th/14th Sector V, Salt Lake, Kolkata - 700091, India Tel. +91 33 4041 8100 Ext: 145
www.mindteck.com
cid:[email protected] cid:[email protected] cid:[email protected] cid:[email protected]
Disclaimer: This message is for the named recipient(s) above and may contain confidential, proprietary or legally privileged information of MINDTECK. If you have received this message in error, please immediately delete all copies of it, and notify the sender. Do not disseminate this message to anyone if you are not the intended recipient.
ü SAVE PAPER - SAVE TREES! THINK BEFORE YOU PRINT. Please do not print this email unless it is absolutely necessary.
@tradingscreen https://github.com/tradingscreen
I am expecting a JMeter-WebSocketSampler jar, which support cookie for real time communication with SignalR. In your last mail I don't find any attachment. I tried with the one https://github.com/maciejzaleski/JMeter-WebSocketSampler/pull/22 that also not working for me.
Thanks Chitta Ranjan
On 2/15/2017 7:07 AM, angelqing wrote:
I'm sorry to reply to you so long ago,Because I saw your mail today.You need the websocket JAR file inside the attachment,about http request cookie I Suggest you added in front of the thread group,Do not know can help you solve your problem.
good luck!
From: ChittaRanjan1981 Date: 2017-02-13 13:14 To: maciejzaleski/JMeter-WebSocketSampler CC: angelqing; Comment Subject: Re: [maciejzaleski/JMeter-WebSocketSampler] Added support for headers and cookies in WebSocket upgrade request (#22) @tradingscreen I am working on Signalr, This is my project requirement hence downloaded websocket version websocket-9.1.1.v20140108, I dont have a good knowledge on JAVA. I am using maciejzaleski websocket sampler in JMeter First time. After a lot of r&d I success to communicate with Signalr via your Websocket sampler. Now my project build got upgraded & they are passing a Cookie Data: .ASPXAUTH=0AE3BF3FE55AAADC5FFEAFE1120F1E45B84AC2C7D227BC8F8E1585E74D14852798F5D27B688D4AFC2C1E494263077178ECBAFC126F4D7D258A21F258779B4B9749BE9D819C51FCBE7D116691F2020FC8EABE622396AA80201872F5C671009EBB in each (Http & WS) request. Via Jmeter cookie manager in each http request cookie handled correctly & requests were passing but my Websocket requests were failing because its not passing the Cookie data. I have gone through all above comments. As I told I can rate myself 1 outof 10 in JVAV. Could you please let me know or send me the required websocket JAR file which handles cookies @ [email protected]. Or any guide line also help me...Please Thanks In Advance. — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/maciejzaleski/JMeter-WebSocketSampler/pull/22#issuecomment-279892493, or mute the thread https://github.com/notifications/unsubscribe-auth/AYisqNg1QaEJVKHWSDM7rHz1hybigg3iks5rclb1gaJpZM4ByXwO.
-- Warm Regards,
Chitta Ranjan Module Lead
Millennium City Information Technology Park, Tower II, Floor - Floor – 9th/14th Sector V, Salt Lake, Kolkata - 700091, India Tel. +91 33 4041 8100 Ext: 145
www.mindteck.com
cid:[email protected] cid:[email protected] cid:[email protected] cid:[email protected]
Disclaimer: This message is for the named recipient(s) above and may contain confidential, proprietary or legally privileged information of MINDTECK. If you have received this message in error, please immediately delete all copies of it, and notify the sender. Do not disseminate this message to anyone if you are not the intended recipient.
ü SAVE PAPER - SAVE TREES! THINK BEFORE YOU PRINT. Please do not print this email unless it is absolutely necessary.
I've a problem with this plugin. It seems to be a race condition. When I subscribe a service via websocket. my service returns 2 messages. The problem occurs when these 2 messages came at the same time. There is an error at WebSocketSampler.java, method: "sample" at the lines below:
if (socket.getResponseMessage() == null || socket.getResponseMessage().isEmpty()) {
sampleResult.setResponseCode("204");
}
Error Message: [Problems]
- Unexpected error: null
java.util.LinkedList$ListItr.checkForComodification(Unknown Source)
java.util.LinkedList$ListItr.next(Unknown Source)
JMeter.plugins.functional.samplers.websocket.ServiceSocket.getResponseMessage(ServiceSocket.java:106)
JMeter.plugins.functional.samplers.websocket.WebSocketSampler.sample(WebSocketSampler.java:155)
org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:465)
org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:410)
org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:241)
java.lang.Thread.run(Unknown Source)
Can you advise?
I have one question. My service returns 2 messages and we don't know which one will come first. Is it possible to hold the sampler until it has received 2 messages instead of checking the response pattern?
Hi,
Please try the available JMeter WebSocket Samplers available at https://bitbucket.org/pjtr/jmeter-websocket-samplers/src/ed555a0f4b5b07855b8061605ac72617d745a176/samples/?at=master
It must resolve your issue.
On 5/5/2017 2:17 PM, buaban wrote:
I've a problem with this plugin. It seems to be a race condition. When I subscribe a service via websocket. my service returns 2 messages. The problem occurs when these 2 messages came at the same time. There is an error at WebSocketSampler.java, method: "sample" at the lines below:
|if (socket.getResponseMessage() == null || socket.getResponseMessage().isEmpty()) { sampleResult.setResponseCode("204"); } |
Error Message: [Problems]
|- Unexpected error: null java.util.LinkedList$ListItr.checkForComodification(Unknown Source) java.util.LinkedList$ListItr.next(Unknown Source) JMeter.plugins.functional.samplers.websocket.ServiceSocket.getResponseMessage(ServiceSocket.java:106) JMeter.plugins.functional.samplers.websocket.WebSocketSampler.sample(WebSocketSampler.java:155) org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:465) org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:410) org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:241) java.lang.Thread.run(Unknown Source) |
Can you advise?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/maciejzaleski/JMeter-WebSocketSampler/pull/22#issuecomment-299413467, or mute the thread https://github.com/notifications/unsubscribe-auth/AYisqHNGGuo9AX3c3ssEvgQXlnC_1hK4ks5r2uIegaJpZM4ByXwO.
--
Regards,
Chitta Ranjan* /Module Lead / *
cid:[email protected] http://www.mindteck.com/
Millennium City Information Technology Park, Tower II, 9C, Sector V, Salt Lake, Kolkata 700091, India. Tel. +91 33 4041 8100; Ext. 157 www.mindteck.com http://www.mindteck.com/
/cid:[email protected]/ http://www.jobs.net/jobs/mindteck/join?joinpath=Extportablejoincid:[email protected] https://www.linkedin.com/company/mindteckcid:[email protected] https://www.facebook.com/Mindteckglobal/cid:[email protected] https://twitter.com/mindteck?lang=en
/Disclaimer: //This message is for the named recipient(s) above and may contain confidential, proprietary or legally privileged information of MINDTECK. If you have received this message in error, please immediately delete all copies of it, and notify the sender. Do not disseminate this message to anyone if you are not the intended recipient./