2 Comments

  • Sutrisno Suryajaya
    Comment actions Permalink

    Hi Chaiwat, thanks for reporting the issue.

     

    This can be due the bot WebSocket connection is closed because of idle connection. The idle timeout mechanism can reside in the WebSocket client (different library have different configuration) or the WebSocket server constraint (our server will drop the WebSocket connection if it is idle for 30 minutes). To prevent this from happening, you can set up a periodic ping (e.g. every 5 seconds) by sending the following payload through the WebSocket:

    {
        "sig": "PING",
        "payload": <string_payload>
    }

    This will ensure that the connection is not idle and stays alive. I have update the sample code with this ping mechanism. 

     

    Please let me know whether the update some code is working for you now :)

    1
  • Chaiwat Wongchuen
    Comment actions Permalink

    Hi Sutrisno Suryajaya

    I try to write this code in function init()

     

    setInterval(() => {

    const PINGBOT= {

    sig :"PING",

    payload:"Ping",

    };

    webSocket.send(JSON.stringify(PINGBOT));

    }, 5000);

    and it's work ! Thank you very much.

     

    0

Post is closed for comments.

Powered by Zendesk