How to keep alive open websocket connection ?

Issue #205 closed
zhaotang ou created an issue

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)

  1. Peter Doornbosch repo owner

    Hi,

    Hmm, interesting 😉. Can you send (email) me the wireshark capture?

    Regards
    Peter

  2. Peter Doornbosch 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.

  3. zhaotang ou 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:

    ‌

  4. Peter Doornbosch 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).

  5. zhaotang ou 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

  6. Peter Doornbosch 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

  7. zhaotang ou reporter

    Thanks Peter, I found the Runtime Controller in JMeter can help me complete the work of receiving, thank you for answering my questions

  8. Log in to comment