How to hangup all calls in a channel immediately when one endpoint becomes unreachable / web sockets connection breaks

We we are using jsSip as our user agent. When one of the endpoints disconnects (websocket). The other endpoint is not hanging up and stays inside the channel for a longer period of time before all endpoints in the channel will hangup. Is there a way to hang up all endpoints inside a channel immediatly when one of the endpoint websocket connection disconnects.

 -- Called PJSIP/1D11C1D0-508F-4F77-8A73-20BB49D6321E
    -- PJSIP/twilio-0000001d connected line has changed. Saving it until answer for PJSIP/D44619BE-AE89-47CD-813A-AED848CA2FC7-0000001c
    -- PJSIP/1D11C1D0-508F-4F77-8A73-20BB49D6321E-0000001e connected line has changed. Saving it until answer for PJSIP/D44619BE-AE89-47CD-813A-AED848CA2FC7-0000001c
    -- PJSIP/1D11C1D0-508F-4F77-8A73-20BB49D6321E-0000001e is ringing
       > 0xffff540d65f0 -- Strict RTP learning after remote address set to: 192.168.164.1:52502
    -- PJSIP/1D11C1D0-508F-4F77-8A73-20BB49D6321E-0000001e answered PJSIP/D44619BE-AE89-47CD-813A-AED848CA2FC7-0000001c
    -- Channel PJSIP/1D11C1D0-508F-4F77-8A73-20BB49D6321E-0000001e joined 'simple_bridge' basic-bridge <b4925c89-f2b5-4c97-87c6-2d9211fa81b7>
    -- Channel PJSIP/D44619BE-AE89-47CD-813A-AED848CA2FC7-0000001c joined 'simple_bridge' basic-bridge <b4925c89-f2b5-4c97-87c6-2d9211fa81b7>
       > 0xffff540d65f0 -- Strict RTP learning after ICE completion
       > 0xffff540d65f0 -- Strict RTP learning after remote address set to: 172.16.171.1:55486
       > 0xffff540d65f0 -- Strict RTP switching to RTP target address 172.16.171.1:55486 as source
       > 0xffff6c2b6db0 -- Strict RTP learning complete - Locking on source address 172.16.171.1:58383
       > 0xffff540d65f0 -- Strict RTP learning complete - Locking on source address 172.16.171.1:55486
    -- Removed contact 'sip:312lfo89@172.16.171.1:60047;transport=ws;x-ast-orig-host=2uf2smuqk2a0.invalid:0' from AOR 'D44619BE-AE89-47CD-813A-AED848CA2FC7' due to shutdown
  == WebSocket connection from '172.16.171.1:60047' closed
  == Contact D44619BE-AE89-47CD-813A-AED848CA2FC7/sip:312lfo89@172.16.171.1:60047;transport=ws;x-ast-orig-host=2uf2smuqk2a0.invalid:0 has been deleted
  == Endpoint D44619BE-AE89-47CD-813A-AED848CA2FC7 is now Unreachable
ubuntu*CLI> pjsip show channels

  Channel:  <ChannelId........................................>  <State.....>  <Time.....>
      Exten: <DialedExten.............>  CLCID: <ConnectedLineCID.......>
==========================================================================================

  Channel: PJSIP/1D11C1D0-508F-4F77-8A73-20BB49D6321E-0000001e/A Up            00:00:26   
      Exten:                             CLCID: "" <+31401234567>

  Channel: PJSIP/D44619BE-AE89-47CD-813A-AED848CA2FC7-0000001c/D Up            00:00:27   
      Exten: 1                           CLCID: "" <1>


Objects found: 2


This was brought up recently at Asterisk 18.x How can we terminate the call when Web browser is exited

There is no way to do it immediately. You can set an RTP timeout or enable session timers to have it hang up after a period of defined time.

Looking at Asterisk 20 Function_PJSIP_ENDPOINT - Asterisk Project - Asterisk Project Wiki and the rtp_timeout. Settings it to 5 seconds it works perfectly.

 res_pjsip_sdp_rtp.c:146 rtp_check_timeout: Disconnecting channel 'PJSIP/1D11C1D0-508F-4F77-8A73-20BB49D6321E-0000002d' for lack of audio RTP activity in 5 seconds

Thank you

If you have a back-end process monitoring a WebSocket connection, then you can indeed detect immediately when a web page is closed. You could then take action on other resources (connected calls etc) associated with that session.

What version of Asterisk?

I’d suggest using the latest version, if the issue still occurs then file an issue[1] with the details. There is no time frame on if or when it would get looked into.

[1] Issues · asterisk/asterisk · GitHub

Monitor the WebSocket connection, then, rather than reply on the RTP timeout.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.