Jigasi and Twilio - can't connect to SIP trunk

Hi all!
I’ve just installed Jitsi meet on Ubuntu 18.04 through the repository which works great.
I’ve then been assigned to also install Jigasi as some of our users sometimes don’t have internet coverage so at least they’ll be able to phone into the meeting or for us to call them and have an audio.
For the SIP part, I’m trying to use Twilio as I already have an account. I thought the process will be pretty straight forward but it seems to pose some real problems for me.
I’ve configured everything in Twilio and then I’ve installed Jigasi through the repo. When it asks me for the sip user, I introduce +phonenumber@sipURI .pstn.twilio.com and for the password the one which I’ve introduced in the credentials section. Then, when I start Jigasi in the logs I always see the following and it’s never registering to Twilio(as it should?):

2019-12-12 18:23:30.025 INFO: [42] org.jitsi.jigasi.SipGateway.registrationStateChanged().105 REG STATE CHANGE ProtocolProviderServiceSipImpl(SIP:+phonenumber@sipURI .pstn.twilio.com) -> RegistrationStateChangeEvent[ oldState=Unregistered; newState=RegistrationState=Registering; reasonCode=-1; reason=null]

2019-12-12 18:24:02.091 INFO: [35] org.jitsi.jigasi.SipGateway.registrationStateChanged().105 REG STATE CHANGE ProtocolProviderServiceSipImpl(SIP:+phonenumber@sipURI .pstn.twilio.com) -> RegistrationStateChangeEvent[ oldState=Registering; newState=RegistrationState=Connection Failed; reasonCode=-1; reason=A timeout occurred while trying to connect to the server.]

PCAP says the following:

▒n▒]▒DE6▒5G▒6▒<▒▒"REGISTER sip:sipURI.pstn.twilio.com SIP/2.0
Call-ID: 3a6db50d26759f23cce29f8116a357e5@0:0:0:0:0:0:0:0
CSeq: 1 REGISTER
From: “sipURI” <sip:username@sipURI .pstn.twilio.com>;tag=46221325
To: “sipURI” <sip:username@sipURI .pstn.twilio.com>
Via: SIP/2.0/UDP 10.0.0.2:5060;branch=z9hG4bK-313434-592f85a7231db68282536220233963fd
Max-Forwards: 70
User-Agent: Jigasi1.1.38-g8f3c241Linux
Expires: 600
Contact: “username” <sip:sipURI@10.0.0.2:5060;transport=udp;registering_acc=sipURI _pstn_twilio_com>;expires=600
Content-Length: 0

▒n▒]▒▒DE6▒5G▒6▒<▒▒"REGISTER sip:sipURI.pstn.twilio.com SIP/2.0
Call-ID: 3a6db50d26759f23cce29f8116a357e5@0:0:0:0:0:0:0:0
CSeq: 1 REGISTER
From: “sipURI” <sip:username@sipURI .pstn.twilio.com>;tag=46221325
To: “sipURI” <sip:username@sipURI .pstn.twilio.com>
Via: SIP/2.0/UDP 10.0.0.2:5060;branch=z9hG4bK-313434-592f85a7231db68282536220233963fd
Max-Forwards: 70
User-Agent: Jigasi1.1.38-g8f3c241Linux
Expires: 600
Contact: “username” <sip:username@10.0.0.2:5060;transport=udp;registering_acc=sipURI _pstn_twilio_com>;expires=600
Content-Length: 0

▒n▒]▒▒DE6▒5G▒6▒<▒▒"REGISTER sip:sipURI.pstn.twilio.com SIP/2.0
Call-ID: 3a6db50d26759f23cce29f8116a357e5@0:0:0:0:0:0:0:0
CSeq: 1 REGISTER
From: “sipURI” <sip:username@sipURI .pstn.twilio.com>;tag=46221325
To: “sipURI” <sip:username@sipURI .pstn.twilio.com>
Via: SIP/2.0/UDP 10.0.0.2:5060;branch=z9hG4bK-313434-592f85a7231db68282536220233963fd
Max-Forwards: 70
User-Agent: Jigasi1.1.38-g8f3c241Linux
Expires: 600
Contact: “sipURI” <sip:username@10.0.0.2:5060;transport=udp;registering_acc=sipURI _pstn_twilio_com>;expires=600
Content-Length: 0

▒n▒]P▒DE6▒5G▒6▒<▒▒"REGISTER sip:sipURI.pstn.twilio.com SIP/2.0
Call-ID: 3a6db50d26759f23cce29f8116a357e5@0:0:0:0:0:0:0:0
CSeq: 1 REGISTER
From: “sipURI” <sip:username@sipURI .pstn.twilio.com>;tag=46221325
To: “sipURI” <sip:username@sipURI .pstn.twilio.com>
Via: SIP/2.0/UDP 10.0.0.2:5060;branch=z9hG4bK-313434-592f85a7231db68282536220233963fd
Max-Forwards: 70
User-Agent: Jigasi1.1.38-g8f3c241Linux
Expires: 600
Contact: “sipURI” <sip:sipURI@10.0.0.2:5060;transport=udp;registering_acc=sipURI _pstn_twilio_com>;expires=600
Content-Length: 0

My sip-communicator.properties file contains the following:

net.java.sip.communicator.impl.protocol.sip.acc1403273890647.ACCOUNT_UID=SIP:+phonenumber@sipURI .pstn.twilio.com
net.java.sip.communicator.impl.protocol.sip.acc1403273890647.PASSWORD=IUFPfGVrRTd0JS8pO0hHYkZk
net.java.sip.communicator.impl.protocol.sip.acc1403273890647.PROTOCOL_NAME=SIP
net.java.sip.communicator.impl.protocol.sip.acc1403273890647.SERVER_ADDRESS=sipURI .pstn.twilio.com
net.java.sip.communicator.impl.protocol.sip.acc1403273890647.USER_ID=username@sipURI .pstn.twilio.com

I have no experience at all with SIPS. My firewall is all down for both ingress and egress but it still doesn’t work.
Anyone has any experience with Twilio and Jigasi? Maybe I’m not defining the user and phone number correctly, I don’t know.
Thank you!
Radu

1 Like

After a little bit of troubleshooting, I’ve managed to make it connect to the Twilio SIP Trunk but now I’m facing another issue.
When I try to call from the conference, I get the following error:

2019-12-13 15:23:42.721 SEVERE: [79] impl.protocol.sip.SipMessageFactory.throwOperationFailedException().2652 Failed to create INVITE request.
javax.sip.SipException: Dialog not yet established – no response!
2019-12-13 15:23:42.734 INFO: [79] org.jitsi.jigasi.SipGatewaySession.onConferenceCallStarted().581 [ctx=1576243421242644481208] Created outgoing call to SipGatewaySession{sipCall=Call: id=1576243422589653816755 peers=1, destination=’+mobilephonenumber’}
2019-12-13 15:23:42.789 INFO: [93] org.jitsi.jigasi.SipGatewaySession.peerStateChanged().1204 [ctx=1576243421242644481208] SIP peer state: Connecting
2019-12-13 15:23:42.978 INFO: [97] org.jitsi.jigasi.SipGatewaySession.peerStateChanged().1204 [ctx=1576243421242644481208] SIP peer state: Alerting Remote User (Ringing)
2019-12-13 15:23:43.205 INFO: [91] service.protocol.media.MediaHandler.registerDynamicPTsWithStream().1003 Dynamic PT map: 126=rtpmap:-1 telephone-event/8000; 111=rtpmap:-1 opus/48000/2 fmtp:useinbandfec=1;minptime=10; 103=rtpmap:-1 unknown/90000;
2019-12-13 15:23:43.209 INFO: [91] service.protocol.media.MediaHandler.registerDynamicPTsWithStream().1020 PT overrides [103->104 ]
2019-12-13 15:23:43.313 INFO: [91] service.protocol.media.CallPeerMediaHandler.start().1961 Starting
2019-12-13 15:23:43.625 INFO: [98] service.protocol.media.MediaHandler.registerDynamicPTsWithStream().1003 Dynamic PT map: 101=rtpmap:-1 telephone-event/8000; 96=rtpmap:-1 opus/48000/2 fmtp:usedtx=1; 98=rtpmap:-1 iLBC/8000; 97=rtpmap:-1 AMR-WB/16000;
2019-12-13 15:23:43.626 INFO: [98] service.protocol.media.MediaHandler.registerDynamicPTsWithStream().1020 PT overrides
2019-12-13 15:23:43.660 INFO: [98] org.jitsi.jigasi.SipGatewaySession.handleCallState().1123 [ctx=1576243421242644481208] Sip call IN_PROGRESS: Call: id=1576243422589653816755 peers=1
2019-12-13 15:23:43.662 INFO: [98] org.jitsi.jigasi.SipGatewaySession.handleCallState().1132 [ctx=1576243421242644481208] SIP call format used: rtpmap:0 PCMU/8000
2019-12-13 15:23:43.665 INFO: [98] org.jitsi.jigasi.SipGatewaySession.peerStateChanged().1204 [ctx=1576243421242644481208] SIP peer state: Connected
2019-12-13 15:23:43.666 INFO: [98] service.protocol.media.CallPeerMediaHandler.start().1961 Starting
2019-12-13 15:23:44.057 INFO: [98] service.protocol.media.TransportManager.sendHolePunchPacket().552 Send NAT hole punch packets
2019-12-13 15:23:44.061 INFO: [91] org.jitsi.jigasi.JvbConference.callStateChanged().1122 [ctx=1576243421242644481208] JVB conference call IN_PROGRESS.
2019-12-13 15:23:45.664 SEVERE: [112] org.jitsi.jigasi.SipGatewaySession.run().1057 [ctx=1576243421242644481208] Stopped receiving RTP for Call: id=1576243422589653816755 peers=1
2019-12-13 15:23:55.505 INFO: [151] org.jitsi.jigasi.SipGatewaySession.handleCallState().1138 [ctx=1576243421242644481208] SIP call ended: CallPeerChangeEvent: type=CallPeerStatusChange oldV=net.java.sip.communicator.service.protocol.CallPeerState:Connected newV=net.java.sip.communicator.service.protocol.CallPeerState:Disconnected for peer=+mobilephonenumber <+mobilephonenumber@domain .sip.us1.twilio.com>;status=Disconnected
2019-12-13 15:23:55.513 INFO: [151] org.jitsi.jigasi.SipGatewaySession.peerStateChanged().1204 [ctx=1576243421242644481208] SIP peer state: Disconnected
2019-12-13 15:24:00.514 INFO: [152] org.jitsi.jigasi.SipGatewaySession.sipCallEnded().629 [ctx=1576243421242644481208] Sip call ended: Call: id=1576243422589653816755 peers=0
2019-12-13 15:24:00.522 INFO: [152] org.jitsi.jigasi.JvbConference.stop().500 [ctx=1576243421242644481208] Removing account Jabber:173920be@meet .domain.com/173920be
2019-12-13 15:24:00.535 INFO: [152] impl.protocol.jabber.OperationSetBasicTelephonyJabberImpl.registrationStateChanged().132 Jingle : OFF
2019-12-13 15:24:00.539 INFO: [152] org.jitsi.jigasi.AbstractGateway.notifyCallEnded().128 [ctx=1576243421242644481208] Removed session for call. Sessions:0
2019-12-13 15:24:00.550 SEVERE: [157] org.jitsi.jigasi.JvbConference.callStateChanged().1114 [ctx=1576243421242644481208] Call change event for different call ? Call: id=15762434219281239972572 peers=0 : null
2019-12-13 15:24:00.565 SEVERE: [99] org.jitsi.impl.neomedia.RTPConnectorOutputStream.log() Failed to send a packet to target /INTERNAL_IP:10000:java.io.IOException: No active socket.
2019-12-13 15:24:00.565 SEVERE: [157] org.jitsi.impl.neomedia.RTPConnectorOutputStream.log() Failed to send a packet to target /INTERNAL_IP:10000:java.io.IOException: No active socket.

When I try to call the conference, I get the following error:

2019-12-13 15:27:59.266 SEVERE: [192] impl.protocol.sip.SipStackSharing.findTargetFor().922 no listeners
2019-12-13 15:27:59.267 SEVERE: [192] impl.protocol.sip.SipStackSharing.processRequest().709 couldn’t find a ProtocolProviderServiceSipImpl to dispatch to

The logs from Twilio look like this:

INVITE
sip:+TWILIO_PHONE_NUMBER@meet.domain.com
2019-12-13 13:27:59 UTC
Request
URL
sip://+TWILIO_PHONE_NUMBER@meet.domain.com
ParametersShow Raw
|To|“sip:+TWILIO_PHONE_NUMBER@meet.domain.com”|
| — | — |
|From|“sip:+MOBILEPHONENUMBER@domain.pstn.twilio.com;tag=56386654_6772d868_06cc428f-40c9-4fae-a127-6b65352e3596”|
Message TextShow Raw
|Msg|“Request timeout with sip:+TWILIO_PHONE_NUMBER@meet.domain.com”|
| — | — |
|ErrorCode|“32011”|
|LogLevel|“WARN”|
Response
Headers
ReasonPhrase Request Timeout
StatusCode 408
Body
No body.

What could I do to narrow down the problem?
Regards,
Radu

Hi,

Did you solve this?
I’m trying to figure out how to get my web hook / twiml to hook up to Jigasi sip.

Any help appreciated.

Jules.

Hey Jules.
Unfortunately I haven’t managed yet to make Jigasi work with Twilio :frowning: but I have also left it aside for the moment. Did you managed to make it work?
Radu

Hi again.
Is there no one who can at least guide us on how to properly set-up Jitsi with Twilio :disappointed:?
Regards,
Radu

Have you tried first using the desktop client to configure and use it with Twillio?

Hi damencho.
Yes, I have already tried that. Any specifics here on what to take into account?
Regards,
Radu

Is it working?

What did you do to get Jigasi work with Twilio for outbound calls?

Was there any solution to this? I’m running into the same problem now. I can’t make the connection through Twilio’s settings.

@ealbers @CorporateComm
Unfortunately I haven’t found any solutions to this, yet.
Maybe @damencho could help us.

I just got twilio and Jitsi working for both inbound and outbound calls. I will try and write up a quick tutorial over the weekend

1 Like

@Jacob_Smith I’d be very interested in seeing your step by step for twilio integration. Trying to do the same thing myself, and frankly, I’m lost.

To connect calls coming in to your conference, you need to:

  1. Purchase a phone number from Twilio.
  2. Have a SIP domain (not SIP Trunking) registered. You will need to create an entry under the authentication section - I recommend the number that you purchased for the username.
  3. Create a TwimlBin named: ToSIPClient
    For initial testing, I recommend putting:
            <?xml version="1.0" encoding="UTF-8"?>
            <Response>
                <Dial answerOnBridge="true">
                    <Sip>
                        sip:YOUR_NUMBER_HERE@YOUR_SIP_NAME.sip.us1.twilio.com
                    </Sip>
                </Dial>
            </Response>

That will redirect the user to siptest conference room on your jitsi server (by default). We can change that later.

  1. When you install Jigasi, it will prompt you for your sip number during install. This is the full path of the number and the SIP domain you registered.
    Example: 15551234567@YOUR_SIP_NAME.sip.us1.twilio.com
    You will the enter the password you created in step 2.

  2. Restarting Jigasi should get you able to dial in to the default conference room.

To send to a custom conference room, you will need to update your ToSIPClient to something like:

<?xml version="1.0" encoding="UTF-8"?>
    <Response>
      	<Gather numDigits="8" action="YOUR_SERVER_ADDRESS_HERE">
          <Say>Please enter the 8 digit room code, followed by the pound key.</Say>
        </Gather>
</Response>

Then, wherever you send that action to, will receive a POST message with a parameter Digits that includes what the user entered. You can then find a conference / meeting, etc. based on however you “link” the two in your database. For us, we have “meetings” that include a Jitsi conference. Each Meeting object gets a random 8 digit number assigned to it. Then, when this endpoint is hit, we look up the meeting based on that 8 digit number, then return the following XML payload to Twilio:

            <?xml version="1.0" encoding="UTF-8"?>
            <Response>
                <Dial answerOnBridge="true">
                    <Sip>
                        sip:YOUR_NUMBER_HERE@YOUR_DOMAIN_HERE.sip.us1.twilio.com?X-Room-Name=MEETING_NAME_HERE
                    </Sip>
                </Dial>
            </Response>

You do need to update your jigasi sip configuration file to include:
net.java.sip.communicator.impl.protocol.sip.acc1403273890647.JITSI_MEET_ROOM_HEADER_NAME=X-Room-Name

Twilio only forwards headers that are prefixed with X- and, by default, Jigasi doesn’t look for headers prefixed with X-.

Please let me know if this helped or if there are further areas that could be clarified. Once I have a bit more time, I’d like to record a video walkthrough on a new server so I’m sure I hit all the steps and hopefully make it easier for people in the future. Let me know what further questions I can help answer!

Just put together a quick tutorial below - take a look and let me know if it helps or if I’m forgetting a few steps and need to go back through our config to see what I missed!

Hi @Jacob_Smith ,

Thanks a lot for the tuturial.
For outgoing calls, do you need do anything in twilio?

Best Regards,
Fernando Gomes

I’ll definitely be giving this a try this week. Thank you for all your hard work!

Yes, sorry, forgot that part of the flow!

You’ll want another TwimlBin called SipClientOutbound with the following:

<?xml version="1.0" encoding="UTF-8"?>
<Response>
    <Dial answerOnBridge="true" callerId="{{#e164}}{{From}}{{/e164}}">{{#e164}}{{To}}{{/e164}}</Dial>
</Response>

Then, on your number’s SIP Domain, paste the URL of your TwimlBin into the Voice Configuration Request URL field. That way, when Twilio gets the “message” from your SIP caller (in this case, Jigasi), it will run the TwimlBin which will then tell twilio to actually execute the call.

https://www.twilio.com/blog/registering-sip-phone-twilio-inbound-outbound was a great resource for me in figuring all of this out (well, that and a health amount of trial and error :laughing: and goes into some more detail on other ways to set things up).

By the way, would anyone be interested in a live walkthrough of setting this all up? I’m by no means an expert and still have to google / troubleshoot a bunch, but there hasn’t been a bunch of video documentation for jitsi / jigasi for a few years now. I figure we could do a live screenshare with questions and answers between anyone on the call and then upload it to YouTube to be a reference for people (heck, I want a reference for myself 6 months from now when I have to upgrade our server, haha (: )

When you say “YOUR_SERVER_ADDRESS_HERE” what do you mean?

You have prosody with ldap auth? After I enable it, inbound calls fails.

Best Regards,
Fernando Gomes