JMeter-WebSocketSampler
JMeter-WebSocketSampler copied to clipboard
Not to able to get websocket connection?any help
Thread Name: Thread Group 1-1 Sample Start: 2015-04-20 13:18:38 EDT Load time: 5010 Connect Time: 0 Latency: 0 Size in bytes: 0 Headers size in bytes: 0 Body size in bytes: 0 Sample Count: 1 Error Count: 1 Response code: 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
[Variables]
- Message count: 0
[Problems]
- Unexpected error: null JMeter.plugins.functional.samplers.websocket.ServiceSocket.sendMessage(ServiceSocket.java:147) JMeter.plugins.functional.samplers.websocket.WebSocketSampler.sample(WebSocketSampler.java:116) org.apache.jmeter.threads.JMeterThread.process_sampler(JMeterThread.java:434) org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:261) java.lang.Thread.run(Unknown Source)
Response headers:
SampleResult fields: ContentType: DataEncoding: UTF-8
have the same problem
I am experiencing same problem. Any pointers would be helpful please
Same issue also not able to provide a loop to generate unique Websocket connections anyone can help?
Same issue when I run a thread group with thread numbers larger than 1. Any existing solution to fix it?
When I track in the code, I see that the session is null actually (session.getRemote().sendString(message); ) and before that, onOpen method wasn't called.
Hello,
I amd using SignalR of Microsoft and I had the same issue: I digged into problem by using wireshark. I found out that Server was returning "http 500". On my side, Solution for this: Encode Token and ConnectionToken on jmeter.
Then next problem appeared: "Http 400" occured. I found another problem java.net.URI. The code in WebSocketSampler.java is like this: URI uri = new URI(protocol, null, domain, -1, path , queryString, null); ın this case querystring was encoded 2 times so the connectiontoken was encoded 2 times, therefore, Server can not understand connectiontoken so it returns HTTP 400. So I fixed the code like this: URI uri = new URI(protocol, null, domain, -1, path + "?" + queryString, null, null);
And Recompiled and installed with maven and put it in Jmeter. Now It is working on my side quite well.
I hope it will help.
Cheers,
Hi,
I cannot find the source code in WebSocketSampler.java: URI uri = new URI(protocol, null, domain, -1, path , queryString, null);
Could you give more detailed info? Thanks.
https://github.com/maciejzaleski/JMeter-WebSocketSampler/archive/version-1.0.2.zip src\main\java\JMeter\plugins\functional\samplers\websocket\WebSocketSampler.java Line 228 Line 230
ceritandogan, Got it, thanks!
The problem is eased but not fixed completely yet. Could you give the code fix details? Thanks!
My problem is when I run a thread group with thread number of n (n > 1), all the thread will failed to connect to the server except the last one always succeed. Now with the fix, When n = 3, I got the last 2 threads succeed to connect to the server except the first one.
My fix done as ceritandogan gave:
if (isProtocolDefaultPort()) {
// return new URI(protocol, null, domain, -1, path, queryString, null);
return new URI(protocol, null, domain, -1, path + "?" + queryString, null, null);
}
// return new URI(protocol, null, domain, Integer.parseInt(getServerPort()), path, queryString, null);
return new URI(protocol, null, domain, Integer.parseInt(getServerPort()), path + "?" + queryString, null, null);
Also, I instrumented logs in WebSocket.java as below:
public void sendMessage(String message) throws IOException {
if (session != null){
logMessage.append(" - Session not null! JMeter.plugins.functional.samplers.websocket.ServiceSocket.sendMessage!").append("\n");
} else {
logMessage.append(" - Session null! JMeter.plugins.functional.samplers.websocket.ServiceSocket.sendMessage!").append("\n");
}
if (session.getRemote() != null)
logMessage.append(" - session.getRemote not null! JMeter.plugins.functional.samplers.websocket.ServiceSocket.sendMessage!").append("\n");
if (message != null)
logMessage.append(" - ").append(message).append(" - mssage! JMeter.plugins.functional.samplers.websocket.ServiceSocket.sendMessage!").append("\n");
session.getRemote().sendString(message);
}
The failed thread's sampler results:
[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
- Session null! JMeter.plugins.functional.samplers.websocket.ServiceSocket.sendMessage!
[Problems]
- Unexpected error: null JMeter.plugins.functional.samplers.websocket.ServiceSocket.sendMessage(ServiceSocket.java:156) >JMeter.plugins.functional.samplers.websocket.WebSocketSampler.sample(WebSocketSampler.java:136) org.apache.jmeter.threads.JMeterThread.process_sampler(JMeterThread.java:434) >org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:261) java.lang.Thread.run(Unknown Source)
The code line numbers in the output are those of the origin source code before I changed any code.
The sampler results show that the session here is Null for the failed user. (- Session null! JMeter.plugins.functional.samplers.websocket.ServiceSocket.sendMessage!)
Any ideas?
@peer2peer I updated jetty to use version 9.3.9.M1 and I am no longer getting this error.
@peer2peer ,I also have this problem,Could you tell me how to solve this problem or giving me your JMeterWebSocketSampler-1.0.2-SNAPSHOT.jar which you have modified.Thanks~~~~
Thread Name: Thread Group 1-1 Sample Start: 2015-04-20 13:18:38 EDT Load time: 5010 Connect Time: 0 Latency: 0 Size in bytes: 0 Headers size in bytes: 0 Body size in bytes: 0 Sample Count: 1 Error Count: 1 Response code: 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 [Variables]
Message count: 0 [Problems]
Unexpected error: null JMeter.plugins.functional.samplers.websocket.ServiceSocket.sendMessage(ServiceSocket.java:147) JMeter.plugins.functional.samplers.websocket.WebSocketSampler.sample(WebSocketSampler.java:116) org.apache.jmeter.threads.JMeterThread.process_sampler(JMeterThread.java:434) org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:261) java.lang.Thread.run(Unknown Source) Response headers:
SampleResult fields: ContentType: DataEncoding: UTF-8
@peer2peer, @conwilly88 & @x00350069 I have updated dependency to mentioned jar files, still facing the issue. Can you guys point me to right direction?
I also met this issue, @peer2peer, @conwilly88 & @x00350069 can you share a fixed jar file? Thanks.