You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Sip.js Reconnection Issue when Web socket connection Lost or Network connectin lost #1095
})
.catch((error) => {
isRegistering = false;
console.error("Error starting the UserAgent:", error);
});
} I’ve reviewed the SIP.js documentation and attempted to use the onDisconnect and onConnect delegates for handling reconnections, but I'm unable to achieve reliable re-registration.
Any guidance or recommendations would be greatly appreciated.
After network reconnection (e.g., switching from Wi-Fi to mobile data), the WebSocket and SIP session reconnect successfully. However, even though the call continues and ICE renegotiation completes without errors, audio is not heard on either side post-reconnection.
I have the same issue - It seems that the local web RTC connection remains in place when the connection is lost and then recovered. There should be a renegotiation or some kind of web RTC rebuild to hook up the session after the reinvite.
After the WebSocket connection is restored, we should restart ICE on both ends. For the remote end, send a re-invite with new ICE parameters in onConnect. After calling userAgent.reconnect in onDisconnect, restart ICE on the RTCPeerConnection as follows:
userAgent.delegate = {
onConnect: async () => {
console.log("Transport connected");
registerer.register().catch((e) => { console.log(Exception while registering: ${e}); });
// Re-invite after network switch
if (invitation && invitation.state !== SIP.SessionState.Terminated) {
await invitation.invite({
sessionDescriptionHandlerOptions: {
offerOptions: {
iceRestart: true
}
}
});
}
},
onDisconnect: (error) => {
console.log("UA disconnected: " + error);
registerer.unregister().catch(() => {
console.log("Unregister failed");
});
// Attempt to reconnect only if network/server dropped the connection
if (error) {
attemptReconnection();
}
},
onInvite: async (incomingInvitation) => {
console.log("Incoming call");
//...
}
}
Activity
greatapps commentedon Dec 14, 2024
Is there any solution on this, How to handle the same ?
shibran commentedon Jan 30, 2025
You have to call reconnection method inside onDisconnect delegate. Like,
m-yunus commentedon Feb 5, 2025
i dont hear anything on when an outgoing call not hearting early media any issue on this
jayparmarmagic commentedon Jul 16, 2025
After network reconnection (e.g., switching from Wi-Fi to mobile data), the WebSocket and SIP session reconnect successfully. However, even though the call continues and ICE renegotiation completes without errors, audio is not heard on either side post-reconnection.
MadEddieFFS commentedon Jul 23, 2025
I have the same issue - It seems that the local web RTC connection remains in place when the connection is lost and then recovered. There should be a renegotiation or some kind of web RTC rebuild to hook up the session after the reinvite.
sravanpurumala commentedon Dec 22, 2025
After the WebSocket connection is restored, we should restart ICE on both ends. For the remote end, send a re-invite with new ICE parameters in onConnect. After calling userAgent.reconnect in onDisconnect, restart ICE on the RTCPeerConnection as follows:
userAgent.delegate = {
onConnect: async () => {
console.log("Transport connected");
registerer.register().catch((e) => { console.log(
Exception while registering: ${e}); });// Re-invite after network switch
if (invitation && invitation.state !== SIP.SessionState.Terminated) {
await invitation.invite({
sessionDescriptionHandlerOptions: {
offerOptions: {
iceRestart: true
}
}
});
}
},
onDisconnect: (error) => {
console.log("UA disconnected: " + error);
registerer.unregister().catch(() => {
console.log("Unregister failed");
});
// Attempt to reconnect only if network/server dropped the connection
if (error) {
attemptReconnection();
}
},
onInvite: async (incomingInvitation) => {
console.log("Incoming call");
//...
}
}