onsip / SIP.js

A simple, intuitive, and powerful JavaScript signaling library
https://sipjs.com
MIT License
1.84k stars 693 forks source link

DTMF "onCallDTMFReceived" and "OnInfo" event not working #1064

Open ElectronMB opened 7 months ago

ElectronMB commented 7 months ago

Describe the bug

When two users are connected with an audio call, after that user 2 types any key from the keypad then I want to handle that key event on user 1 side whatever user 2 types like "1" or "#". For the above case, I make logic like that.

1) on the keypad button click:

  const onKeyPadButtonClick = (number: string) => {
        const options = {
          requestOptions: {
            body: {
              contentDisposition: 'render',
              contentType: 'application/dtmf-relay',
              content: `Signal=${number}\r\nDuration=100`,
            },
          },
        };
        simpleUserRef.current?.session?.info(options);   
  };

2) to handle an event of DTMF tone and event:

useEffect(() => {
    if (simpleUserRef.current) {
      simpleUserRef.current.delegate = {
        onInfo: (info: any) => {
          console.log('Info,,,,,', info);
        },
        onCallDTMFReceived: (dtmf: any, duration: any) => {
          console.log('onCallDTMFReceived', dtmf, duration);
        },
      };
      if (simpleUserRef.current.session) {
        simpleUserRef.current.session.delegate = {
          onRefer: (dtmf: any, tone: any, duration: any) => {
            console.log('onRefer', dtmf, tone, duration);
          },
          onInfo: (info: any) => {
            console.log('Info,,,,,', info);
          },
        };
      }
    }
  }, []);

Note: In the above case I used SimpleUser to setup the sip.js connection.

Bug :

I didn't get anything in the above "onInfo" and "onCallDTMFReceived" event listener so how can I get it?

I want to handle the DTMF to another side of to one connection.

Expected behavior as per the expected behavior, all the logs are displayed whenever some user press any key from the keypad.

Observed behavior I didn't get anything in the above "onInfo" and "onCallDTMFReceived" event listener so how can I get it?

Environment Information

thebium commented 7 months ago

I've also have been testing receiving DTMF INFO messages. I can send DTMF and can see in console that it is sent and accepted by PBX system. If the DTMF is sent from mobile phone to the WebPhone then I don't see any INFO messages on the console, that it was received.

sip.js --> 0.21.2 Chrome: Version 119.0.6045.202 (Official Build) (64-bit) PBX Server: Asterisk

ElectronMB commented 7 months ago

I've also seen a log that DTMF sends successfully, but I didn't get anything in the above "onInfo" and "onCallDTMFReceived" event listener so, how can I get it?

I am trying to call webphone to another webphone.

thebium commented 7 months ago

We managed to figure out what was the problem. sip.js can only handle SIP INFO message DTMF messages. Our webphone was setup to handle only RFC2833 DTMF messages and that's why sip.js did not see them.

ElectronMB commented 7 months ago

Okay, so how can I get that dial keypad DTMF do you have a solution for that please share it so I can implement it.

you said the RFC2833 DTMF message is handle by webphone so how can I do this into project?

thebium commented 7 months ago

I said that sip.js does not handle RFC2833 DTMF messages and you should configure your PBX extension for Webphone to handle SIP INFO DTMF messages.

ElectronMB commented 7 months ago

Okay, Can you please share a reference on how we can configure in PBX extension?