How to keep alive open websocket connection ?
Hello Peter. I have a problem. My test process is to create a websocker connection, and then send data every 15 seconds, but after a few hours, the connection closes by itself, and the packet capture on wireshark shows tcp windowzero. I don't know the cause of this problem
Comments (9)
-
repo owner -
reporter - attached Server.pcapng
- attached client.pcapng
I put the wireshark result in the attachment,ip:10.6.4.144 is client,ip:10.6.2.20 is sever
-
repo owner Seems your server is sending data to the client that the client does not read or does not read fast enough.
Do you ever read data in the JMeter test script? If not: you probably have to.
-
reporter I tried to read the data, but the tcp window still appears. Is it possible because of the socker cache? Or is it because my reading speed is not enough? The following is my script flow:
â
-
repo owner Image what happens when the server sends back 2 messages for every message you sendâŚ. You are only reading one for every message you send, so in each loop iteration one message will stay in the tcp receive buffer. When the buffer is full, flow control will let the server know it should stop sending (zero window messages).
-
reporter Thank you for answering this question for me, but I have one more question. What I actually need is to send data every 15 seconds, but how do I continue to receive information? There is also whether the receiving timeout needs to be given to 999999, otherwise there will be no data
-
repo owner If you can determine how many messages are send by the server in those 15 seconds, you can replace the single read by a loop that reads that many messages, then waits 15 seconds and sends another message.
If the number of messages that is sent is dynamic, and you absolutely need to send a message exact each 15 seconds, youâll have to setup a loop that repeats reading until 15 seconds have passed. JMeter provides all kinds of controllers for such tasks, including controllers that allow you use same scripting; with this it must be possible to create such a loop. Note that is all just normal JMeter stuff, if you search for it you should be able to find enough examples to get you going.
Note that the âsingle read sampleâ as an option to do an optional read, i.e. it wonât generate an error if it does not read any message during the wait time; youâll want to use that when youâre reading a message that might not arrive.
Hth
Peter -
reporter Thanks Peter, I found the Runtime Controller in JMeter can help me complete the work of receiving, thank you for answering my questions
-
repo owner - changed status to closed
- Log in to comment
Hi,
Hmm, interesting
. Can you send (email) me the wireshark capture?
Regards
Peter