Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling a phone number through a custom SIP Trunk #656

Open
EricBourque opened this issue Jan 15, 2022 · 16 comments
Open

Calling a phone number through a custom SIP Trunk #656

EricBourque opened this issue Jan 15, 2022 · 16 comments

Comments

@EricBourque
Copy link

Is is possible to call a local/international phone number? I am using a SIP provider, the registration is successfull.
How parameter do I need to use in SIPUserAgent.Call to call a GSM phone number?
Do I need to use the complex SIPCallDescriptor? What should I fill in?
Thanks

@sipsorcery
Copy link
Member

Calling the PSTN is generally just the same as callling any other SIP end point.

You should be able to sue the simpler SIPUserAgent.Call overload. The full SIPCallDescriptor is only needed when more exotic parameters are required.

@EricBourque
Copy link
Author

So if I want to call a phone number, what should the destination be?
For example I want to call +4179 435 0001, var callResult = await ua.Call("41794350001", "myuser", "mypass", rtpSession);
That gives me a SIPClientUserAgent DNS failure resolving 41795155526 in 2255.21ms. Call cannot proceed.

@sipsorcery
Copy link
Member

var callResult = await ua.Call("sip:[email protected]", "myuser", "mypass", rtpSession);

@EricBourque
Copy link
Author

Thanks for the quick feedback, you are fast!
I think I am very close now. FYI, I did test this with a payed C# voice SDK so I know it is not some issue with the SIP trunk.
[17:50:54 DBG] Starting SIPRegistrationUserAgent for sip:[email protected], callback period 175s.
[17:50:54 DBG] Starting registration for sip:[email protected].
[17:50:54 DBG] Request Sent udp:192.168.1.201:5060<-udp:192.76.120.10:5060: REGISTER sip:sip.telnyx.com SIP/2.0.
[17:50:54 DBG] Response Received udp:0.0.0.0:5060<-udp:192.76.120.10:5060: REGISTER 401 Unauthorized.
[17:50:54 DBG] Server response Unauthorised received for sip:[email protected].
[17:50:54 DBG] SIP DNS SRV for sip:sip.telnyx.com resolved to sip-anycast1.telnyx.com. and port 5060.
[17:50:54 DBG] Request Sent udp:192.168.1.201:5060<-udp:192.76.120.10:5060: REGISTER sip:sip.telnyx.com SIP/2.0.
[17:50:55 DBG] Response Received udp:0.0.0.0:5060<-udp:192.76.120.10:5060: REGISTER 200 OK.
[17:50:55 DBG] Server auth response Ok received for sip:[email protected].
[17:50:55 DBG] SIPRegistrationUserAgent was successful, scheduling next registration to sip:[email protected] in 173s.
[17:51:22 DBG] calling sip:[email protected].
[17:51:22 DBG] Starting call to sip:[email protected].
[17:51:22 DBG] SIP DNS SRV for sip:[email protected] resolved to sip-anycast1.telnyx.com. and port 5060.
[17:51:22 DBG] Call progressing, resolved sip:[email protected] to udp:192.76.120.10:5060.
DNS lookup result for sip:[email protected]: udp:192.76.120.10:5060.
[17:51:23 DBG] CreateRtpSocket attempting to create and bind RTP socket(s) on [::]:0.
[17:51:23 DBG] CreateBoundUdpSocket attempting to create and bind UDP socket(s) on [::]:0.
[17:51:23 DBG] CreateBoundUdpSocket successfully bound on [::]:57724, dual mode True.
[17:51:23 DBG] CreateBoundUdpSocket attempting to create and bind UDP socket(s) on [::]:57725.
[17:51:23 DBG] CreateBoundUdpSocket successfully bound on [::]:57725, dual mode True.
[17:51:23 DBG] Successfully bound RTP socket [::]:57724 (dual mode True) and control socket [::]:57725 (dual mode True).
[17:51:23 DBG] RTPChannel for [::]:57724 started.
[17:51:23 DBG] CreateRtpSocket attempting to create and bind RTP socket(s) on [::]:0.
[17:51:23 DBG] CreateBoundUdpSocket attempting to create and bind UDP socket(s) on [::]:0.
[17:51:23 DBG] CreateBoundUdpSocket successfully bound on [::]:57726, dual mode True.
[17:51:23 DBG] CreateBoundUdpSocket attempting to create and bind UDP socket(s) on [::]:57727.
[17:51:23 DBG] CreateBoundUdpSocket successfully bound on [::]:57727, dual mode True.
[17:51:23 DBG] Successfully bound RTP socket [::]:57726 (dual mode True) and control socket [::]:57727 (dual mode True).
[17:51:23 DBG] RTPChannel for [::]:57726 started.
[17:51:23 DBG] SIPClientUserAgent attempting to resolve sip.telnyx.com.
[17:51:23 DBG] SIP DNS SRV for sip:[email protected] resolved to sip-anycast1.telnyx.com. and port 5060.
[17:51:23 DBG] SIPClientUserAgent resolved sip.telnyx.com to udp:192.76.120.10:5060 in 28.34ms.
[17:51:23 DBG] UAC commencing call to sip:[email protected]:5060.
[17:51:23 DBG] Request Sent udp:192.168.1.201:5060<-udp:192.76.120.10:5060: INVITE sip:[email protected] SIP/2.0.
[17:51:23 DBG] Response Received udp:0.0.0.0:5060<-udp:192.76.120.10:5060: INVITE 100 Telnyx Trying.
[17:51:23 DBG] Information response 100 Telnyx Trying for sip:[email protected].
[17:51:23 DBG] Call trying: 100 Telnyx Trying.
[17:51:23 DBG] Response Received udp:0.0.0.0:5060<-udp:192.76.120.10:5060: INVITE 407 Proxy Authentication Required.
[17:51:23 DBG] Request Sent udp:192.168.1.201:5060<-udp:192.76.120.10:5060: ACK sip:[email protected] SIP/2.0.
[17:51:24 DBG] Response 407 Proxy Authentication Required for sip:[email protected].
[17:51:24 DBG] Forward leg failed, authentication was requested but no credentials were available.
[17:51:24 WRN] Call attempt to sip:[email protected] failed with Authentication requested when no credentials available.
[17:51:24 DBG] Call failed: Authentication requested when no credentials available.
[17:51:24 DBG] Ready

@sipsorcery
Copy link
Member

Did you set the username and password on your call attempt?

[17:51:24 DBG] Forward leg failed, authentication was requested but no credentials were available.
[17:51:24 WRN] Call attempt to sip:[email protected] failed with Authentication requested when no credentials available.
[17:51:24 DBG] Call failed: Authentication requested when no credentials available.

Note that registrations and calls are separate SIP worklfows. You probably don't need to register to place an outgoing call. Typically you only need to register if you want to receive a call.

@EricBourque
Copy link
Author

Yes I did. I also found this thread if it helps: http:https://forum.sipsorcery.com/viewtopic.php?t=2910
I have tried GetStartedNetFramework and SIPCallServer with and without registration.

@EricBourque
Copy link
Author

Here is the output with the simple GetStartedFramework.
SIPSorcery Getting Started Demo
[18:18:44 DBG] CreateRtpSocket attempting to create and bind RTP socket(s) on [::]:0.
[18:18:44 DBG] CreateBoundUdpSocket attempting to create and bind UDP socket(s) on [::]:0.
[18:18:44 DBG] CreateBoundUdpSocket even port required, closing socket on [::]:54149 and retrying on 54150.
[18:18:44 DBG] CreateBoundUdpSocket attempting to create and bind UDP socket(s) on [::]:54151.
[18:18:44 DBG] CreateBoundUdpSocket successfully bound on [::]:54151, dual mode True.
[18:18:44 DBG] Successfully bound RTP socket [::]:54150 (dual mode True) and control socket [::]:54151 (dual mode True).
[18:18:44 DBG] RTPChannel for [::]:54150 started.
[18:18:44 DBG] SIPClientUserAgent attempting to resolve sip.telnyx.com.
[18:18:45 DBG] SIP DNS SRV for sip:[email protected] resolved to sip-anycast1.telnyx.com. and port 5060.
[18:18:45 DBG] SIPClientUserAgent resolved sip.telnyx.com to udp:192.76.120.10:5060 in 135.51ms.
[18:18:45 DBG] UAC commencing call to sip:[email protected]:5060.
[18:18:45 DBG] CreateBoundUdpSocket attempting to create and bind UDP socket(s) on 0.0.0.0:0.
[18:18:45 DBG] CreateBoundUdpSocket successfully bound on 0.0.0.0:54155.
[18:18:45 INF] SIP UDP Channel created for udp:0.0.0.0:54155.
[18:18:45 DBG] Information response 100 Telnyx Trying for sip:[email protected].
[18:18:45 INF] Call attempt to sip:[email protected] received a trying response INVITE 100 Telnyx Trying.
[18:18:45 DBG] Response 407 Proxy Authentication Required for sip:[email protected].
[18:18:45 DBG] Information response 100 Telnyx Trying for sip:[email protected].
[18:18:45 INF] Call attempt to sip:[email protected] received a trying response INVITE 100 Telnyx Trying.
[18:18:46 DBG] Information response 180 Ringing for sip:[email protected].
[18:18:46 INF] Call attempt to sip:[email protected] received a ringing response INVITE 180 Ringing.
[18:18:46 DBG] Response 503 Service Unavailable for sip:[email protected].
[18:18:46 WRN] Call attempt was answered with failure response INVITE 503 Service Unavailable.
Call result failure.

@EricBourque
Copy link
Author

Wireshark trace:
INVITE sip:[email protected] SIP/2.0
Via: SIP/2.0/UDP 192.168.1.201:50637;branch=z9hG4bK142db5f5bde24a76a472785dc9f4653c;rport
To: sip:[email protected]:5060
From: sip:[email protected];tag=RROJYMXRUR
Call-ID: f7dc954724b34a1b930df4232030e0ae
CSeq: 1 INVITE
Contact: sip:[email protected]:50637
Max-Forwards: 70
User-Agent: sipsorcery_v6.0.4.0
Supported: replaces, norefersub, 100rel
Content-Length: 310
Content-Type: application/sdp

v=0
o=- 1015631504 0 IN IP4 127.0.0.1
s=sipsorcery
c=IN IP4 192.168.1.201
t=0 0
m=audio 50632 RTP/AVP 0 8 9 101
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:9 G722/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=sendrecv
a=ssrc:1637024955 cname:7cdd2e40-90ce-4009-8657-c551c20b80ca
INVITE sip:[email protected] SIP/2.0
Via: SIP/2.0/UDP 192.168.1.201:50637;branch=z9hG4bK142db5f5bde24a76a472785dc9f4653c;rport
To: sip:[email protected]:5060
From: sip:[email protected];tag=RROJYMXRUR
Call-ID: f7dc954724b34a1b930df4232030e0ae
CSeq: 1 INVITE
Contact: sip:[email protected]:50637
Max-Forwards: 70
User-Agent: sipsorcery_v6.0.4.0
Supported: replaces, norefersub, 100rel
Content-Length: 310
Content-Type: application/sdp

v=0
o=- 1015631504 0 IN IP4 127.0.0.1
s=sipsorcery
c=IN IP4 192.168.1.201
t=0 0
m=audio 50632 RTP/AVP 0 8 9 101
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:9 G722/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=sendrecv
a=ssrc:1637024955 cname:7cdd2e40-90ce-4009-8657-c551c20b80ca
SIP/2.0 100 Telnyx Trying
Via: SIP/2.0/UDP 192.168.1.201:50637;branch=z9hG4bK142db5f5bde24a76a472785dc9f4653c;rport=50637;received=178.199.204.246
To: sip:[email protected]:5060
From: sip:[email protected];tag=RROJYMXRUR
Call-ID: f7dc954724b34a1b930df4232030e0ae
CSeq: 1 INVITE
Server: Telnyx SIP Proxy
Content-Length: 0

SIP/2.0 407 Proxy Authentication Required
Via: SIP/2.0/UDP 192.168.1.201:50637;received=178.199.204.246;branch=z9hG4bK142db5f5bde24a76a472785dc9f4653c;rport=50637
From: sip:[email protected];tag=RROJYMXRUR
To: sip:[email protected]:5060;tag=Hgc70XHg540tm
Call-ID: f7dc954724b34a1b930df4232030e0ae
CSeq: 1 INVITE
Accept: application/sdp
Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REFER, NOTIFY
Supported: path
Allow-Events: talk, hold, conference, refer
Proxy-Authenticate: Digest realm="sip.telnyx.com", nonce="e6b88032-be55-4cec-b461-6cf196868987", algorithm=MD5, qop="auth", opaque="f217c8ce-c56a-4a7b-bdeb-a6598a1f4062/10.13.38.4"
Content-Length: 0

ACK sip:[email protected] SIP/2.0
Via: SIP/2.0/UDP 192.168.1.201:50637;branch=z9hG4bK142db5f5bde24a76a472785dc9f4653c;rport
To: sip:[email protected]:5060;tag=Hgc70XHg540tm
From: sip:[email protected];tag=RROJYMXRUR
Call-ID: f7dc954724b34a1b930df4232030e0ae
CSeq: 1 ACK
Max-Forwards: 70
Content-Length: 0

ACK sip:[email protected] SIP/2.0
Via: SIP/2.0/UDP 192.168.1.201:50637;branch=z9hG4bK142db5f5bde24a76a472785dc9f4653c;rport
To: sip:[email protected]:5060;tag=Hgc70XHg540tm
From: sip:[email protected];tag=RROJYMXRUR
Call-ID: f7dc954724b34a1b930df4232030e0ae
CSeq: 1 ACK
Max-Forwards: 70
Content-Length: 0

INVITE sip:[email protected] SIP/2.0
Via: SIP/2.0/UDP 192.168.1.201:50637;branch=z9hG4bKdca14f7d68bd4fffb42e61089fe1e3d8;rport
To: sip:[email protected]:5060
From: sip:[email protected];tag=RROJYMXRUR
Call-ID: f7dc954724b34a1b930df4232030e0ae
CSeq: 2 INVITE
Contact: sip:[email protected]:50637
Max-Forwards: 70
User-Agent: sipsorcery_v6.0.4.0
Proxy-Authorization: Digest username="myuser",realm="sip.telnyx.com",nonce="e6b88032-be55-4cec-b461-6cf196868987",uri="sip:[email protected]",response="cf05d0adf0e6f3a67b9c03b746dc6799",cnonce="1234114341",nc=00000001,qop=auth,opaque="f217c8ce-c56a-4a7b-bdeb-a6598a1f4062/10.13.38.4",algorithm=MD5
Supported: replaces, norefersub, 100rel
Content-Length: 310
Content-Type: application/sdp

v=0
o=- 1015631504 0 IN IP4 127.0.0.1
s=sipsorcery
c=IN IP4 192.168.1.201
t=0 0
m=audio 50632 RTP/AVP 0 8 9 101
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:9 G722/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=sendrecv
a=ssrc:1637024955 cname:7cdd2e40-90ce-4009-8657-c551c20b80ca
INVITE sip:[email protected] SIP/2.0
Via: SIP/2.0/UDP 192.168.1.201:50637;branch=z9hG4bKdca14f7d68bd4fffb42e61089fe1e3d8;rport
To: sip:[email protected]:5060
From: sip:[email protected];tag=RROJYMXRUR
Call-ID: f7dc954724b34a1b930df4232030e0ae
CSeq: 2 INVITE
Contact: sip:[email protected]:50637
Max-Forwards: 70
User-Agent: sipsorcery_v6.0.4.0
Proxy-Authorization: Digest username="myuser",realm="sip.telnyx.com",nonce="e6b88032-be55-4cec-b461-6cf196868987",uri="sip:[email protected]",response="cf05d0adf0e6f3a67b9c03b746dc6799",cnonce="1234114341",nc=00000001,qop=auth,opaque="f217c8ce-c56a-4a7b-bdeb-a6598a1f4062/10.13.38.4",algorithm=MD5
Supported: replaces, norefersub, 100rel
Content-Length: 310
Content-Type: application/sdp

v=0
o=- 1015631504 0 IN IP4 127.0.0.1
s=sipsorcery
c=IN IP4 192.168.1.201
t=0 0
m=audio 50632 RTP/AVP 0 8 9 101
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:9 G722/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=sendrecv
a=ssrc:1637024955 cname:7cdd2e40-90ce-4009-8657-c551c20b80ca
SIP/2.0 100 Telnyx Trying
Via: SIP/2.0/UDP 192.168.1.201:50637;branch=z9hG4bKdca14f7d68bd4fffb42e61089fe1e3d8;rport=50637;received=178.199.204.246
To: sip:[email protected]:5060
From: sip:[email protected];tag=RROJYMXRUR
Call-ID: f7dc954724b34a1b930df4232030e0ae
CSeq: 2 INVITE
Server: Telnyx SIP Proxy
Content-Length: 0

SIP/2.0 180 Ringing
Via: SIP/2.0/UDP 192.168.1.201:50637;received=178.199.204.246;branch=z9hG4bKdca14f7d68bd4fffb42e61089fe1e3d8;rport=50637
Record-Route: sip:10.255.0.1;transport=tcp;r2=on;lr;ftag=RROJYMXRUR
Record-Route: sip:192.76.120.10;r2=on;lr;ftag=RROJYMXRUR
From: sip:[email protected];tag=RROJYMXRUR
To: sip:[email protected]:5060;tag=jS5Z2r2K2DQDg
Call-ID: f7dc954724b34a1b930df4232030e0ae
CSeq: 2 INVITE
Contact: sip:[email protected]:5070;transport=tcp
Accept: application/sdp
Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REFER, NOTIFY
Supported: path
Allow-Events: talk, hold, conference, refer
Content-Length: 0
X-Telnyx-Session-ID: 90f3202e-7628-11ec-aaa5-02420a0d7f68
X-Telnyx-Leg-ID: 90f30fc6-7628-11ec-b7b7-02420a0d7f68

SIP/2.0 503 Service Unavailable
Via: SIP/2.0/UDP 192.168.1.201:50637;received=178.199.204.246;branch=z9hG4bKdca14f7d68bd4fffb42e61089fe1e3d8;rport=50637
Max-Forwards: 69
From: sip:[email protected];tag=RROJYMXRUR
To: sip:[email protected]:5060;tag=jS5Z2r2K2DQDg
Call-ID: f7dc954724b34a1b930df4232030e0ae
CSeq: 2 INVITE
Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REFER, NOTIFY
Supported: path
Allow-Events: talk, hold, conference, refer
Reason: Q.850;cause=41;text="NORMAL_TEMPORARY_FAILURE"
Content-Length: 0

ACK sip:[email protected] SIP/2.0
Via: SIP/2.0/UDP 192.168.1.201:50637;branch=z9hG4bKdca14f7d68bd4fffb42e61089fe1e3d8;rport
To: sip:[email protected]:5060;tag=jS5Z2r2K2DQDg
From: sip:[email protected];tag=RROJYMXRUR
Call-ID: f7dc954724b34a1b930df4232030e0ae
CSeq: 2 ACK
Max-Forwards: 70
Proxy-Authorization: Digest username="myuser",realm="sip.telnyx.com",nonce="e6b88032-be55-4cec-b461-6cf196868987",uri="sip:[email protected]",response="cf05d0adf0e6f3a67b9c03b746dc6799",cnonce="1234114341",nc=00000001,qop=auth,opaque="f217c8ce-c56a-4a7b-bdeb-a6598a1f4062/10.13.38.4",algorithm=MD5
Content-Length: 0

ACK sip:[email protected] SIP/2.0
Via: SIP/2.0/UDP 192.168.1.201:50637;branch=z9hG4bKdca14f7d68bd4fffb42e61089fe1e3d8;rport
To: sip:[email protected]:5060;tag=jS5Z2r2K2DQDg
From: sip:[email protected];tag=RROJYMXRUR
Call-ID: f7dc954724b34a1b930df4232030e0ae
CSeq: 2 ACK
Max-Forwards: 70
Proxy-Authorization: Digest username="myuser",realm="sip.telnyx.com",nonce="e6b88032-be55-4cec-b461-6cf196868987",uri="sip:[email protected]",response="cf05d0adf0e6f3a67b9c03b746dc6799",cnonce="1234114341",nc=00000001,qop=auth,opaque="f217c8ce-c56a-4a7b-bdeb-a6598a1f4062/10.13.38.4",algorithm=MD5
Content-Length: 0

@EricBourque
Copy link
Author

ping

@sipsorcery
Copy link
Member

[18:18:46 DBG] Response 503 Service Unavailable for sip:[email protected].

That looks to be your problem. Have you tried different number ofrmats? Perhaps you need to use 00 instead of +.

@EricBourque
Copy link
Author

Yes, I have tried 00, + and just 41...
Always the same answer.
I could try with a different SIP trunk but this one works fine with other softphones.

@sipsorcery
Copy link
Member

Ok, could be some other SIP interop issue then. It's a bit beyond the support offered on this repo to track that down unless someone else reading this happens to have solved the same problem.

@EricBourque
Copy link
Author

Well.. I could try to get it working by comparing the wireshark to a wireshark from a different softphone that actually works but this could take allot of time. Would you consider accepting modifications to the source code if I can find what is wrong?

@sipsorcery
Copy link
Member

Would you consider accepting modifications to the source code if I can find what is wrong?

Sure, PR's are always welcome!

@EricBourque
Copy link
Author

Just before I commit to this, can I have a 10-15 minute call with you (manager?) at some point? I want to go through what I plan to use sipsorcery for. My company works with audio/video streaming tech.

@sipsorcery
Copy link
Member

Can't help you with that one, sorry.

I did some consulting in the SIP/WebRTC space related to this project for a little while but then got a real job again. Other than snatches of time to sporadically maintain this library I don't have any bandwidth for anything else at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants