Keep alive response is not effective

Hello
Iam doing RTMS with ZCC, using raw websocket spec, no sdk

Iam successfully done all the signalling and media handshakes, also getting the audio as expected. However, the Keep-Alive does not work for me. After 5 keep-alive requests which are all responsed back, the server actively closed the connection

Request:{"msg_type":12,"sequence":0,"timestamp":1782958602937}
Response:{"msg_type":13,"timestamp":1782958602937}
Request:{"msg_type":12,"sequence":1,"timestamp":1782958612938}
Response:{"msg_type":13,"timestamp":1782958612938}
Request:{"msg_type":12,"sequence":2,"timestamp":1782958622939}
Response:{"msg_type":13,"timestamp":1782958622939}
Request:{"msg_type":12,"sequence":3,"timestamp":1782958632947}
Response:{"msg_type":13,"timestamp":1782958632947}
Request:{"msg_type":12,"sequence":4,"timestamp":1782958642943}
Response:{"msg_type":13,"timestamp":1782958642943}

I do have extract the timestamp from request message for the response
I also tried to extract “sequence” from the request and have it in the response, but did not help
Please advise
Thank you

@MinhCm this looks ok, for the keep alive you need to respond to both signaling and media server.

If you are using raw websocket instead of SDK, you can take a look at some of the samples here

in NodeJS, I’m doing something like this . Both of them do similar things, just that there is slight variations in programming style.

//media server

if (msg.msg_type === 12) {
mediaWs.send(JSON.stringify({
msg_type: 13,
timestamp: msg.timestamp,
}));
}

//signaling server
// Respond to keep-alive requests
if (msg.msg_type === 12) { // KEEP_ALIVE_REQ
const keepAliveResponse = {
msg_type: 13, // KEEP_ALIVE_RESP
timestamp: msg.timestamp,
};
console.log(‘Responding to Signaling KEEP_ALIVE_REQ:’, keepAliveResponse);
ws.send(JSON.stringify(keepAliveResponse));
}