"SIP/2.0 488 Not acceptable here" error - sip

I am new to MjSip and I use MjUa for creating a client. I want to connect to a asterisk server. it support G.711 but I can not config my app.
I use this config:
media=audio 4000 rtp/avp {audio 0 PCMU 8000 160, audio 8 PCMA 8000 160}
but i still get 488 error
please help me. how change "MjUa" config file?
here is all message log:
INVITE sip:57#192.168.0.254:5060 SIP/2.0
Via: SIP/2.0/UDP 192.168.0.57:5060;rport;branch=z9hG4bK2bfdff77
Max-Forwards: 70
To: "Alice" <sip:57#192.168.0.254:5060>
From: "aziz" <sip:157#192.168.0.254>;tag=350164683297
Call-ID: 728007708208#192.168.0.57
CSeq: 1 INVITE
Contact: <sip:157#192.168.0.57>
Expires: 3600
User-Agent: mjsip 1.7
Content-Length: 141
Content-Type: application/sdp
v=0
o=157 0 0 IN IP4 192.168.0.57
s=-
c=IN IP4 192.168.0.57
t=0 0
m=audio 4000 rtp/avp 0 8
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
-----End-of-message-----
1365314026097: 10:23:46.097 Sun 07 Apr 2013, 192.168.0.254:5060/udp (519 bytes) received
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 192.168.0.57:5060;branch=z9hG4bK2bfdff77;received=192.168.0.57;rport=5060
From: "aziz" <sip:157#192.168.0.254>;tag=350164683297
To: "Alice" <sip:57#192.168.0.254:5060>;tag=as3f160681
Call-ID: 728007708208#192.168.0.57
CSeq: 1 INVITE
Server: FPBX-2.8.1(1.8.11.0)
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH
Supported: replaces, timer
WWW-Authenticate: Digest algorithm=MD5, realm="asterisk", nonce="6e640e9a"
Content-Length: 0
-----End-of-message-----
1365314026107: 10:23:46.107 Sun 07 Apr 2013, 192.168.0.254:5060/udp (326 bytes) sent
ACK sip:57#192.168.0.254:5060 SIP/2.0
Via: SIP/2.0/UDP 192.168.0.57:5060;rport;branch=z9hG4bK2bfdff77
Max-Forwards: 70
To: "Alice" <sip:57#192.168.0.254:5060>;tag=as3f160681
From: "aziz" <sip:157#192.168.0.254>;tag=350164683297
Call-ID: 728007708208#192.168.0.57
CSeq: 1 ACK
User-Agent: mjsip 1.7
Content-Length: 0
-----End-of-message-----
1365314026151: 10:23:46.151 Sun 07 Apr 2013, 192.168.0.254:5060/udp (706 bytes) sent
INVITE sip:57#192.168.0.254:5060 SIP/2.0
Via: SIP/2.0/UDP 192.168.0.57:5060;rport;branch=z9hG4bK644461b7
Max-Forwards: 70
To: "Alice" <sip:57#192.168.0.254:5060>
From: "aziz" <sip:157#192.168.0.254>;tag=350164683297
Call-ID: 728007708208#192.168.0.57
CSeq: 2 INVITE
Contact: <sip:157#192.168.0.57>
Expires: 3600
User-Agent: mjsip 1.7
Authorization: Digest username="157", realm="asterisk", nonce="6e640e9a", uri="sip:57#192.168.0.254:5060", algorithm=MD5, response="84ff5e12b8325a153e09ac2e316f5b1f"
Content-Length: 141
Content-Type: application/sdp
v=0
o=157 0 0 IN IP4 192.168.0.57
s=-
c=IN IP4 192.168.0.57
t=0 0
m=audio 4000 rtp/avp 0 8
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
-----End-of-message-----
1365314026152: 10:23:46.152 Sun 07 Apr 2013, 192.168.0.254:5060/udp (450 bytes) received
SIP/2.0 488 Not acceptable here
Via: SIP/2.0/UDP 192.168.0.57:5060;branch=z9hG4bK644461b7;received=192.168.0.57;rport=5060
From: "aziz" <sip:157#192.168.0.254>;tag=350164683297
To: "Alice" <sip:57#192.168.0.254:5060>;tag=as3f160681
Call-ID: 728007708208#192.168.0.57
CSeq: 2 INVITE
Server: FPBX-2.8.1(1.8.11.0)
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH
Supported: replaces, timer
Content-Length: 0
-----End-of-message-----
1365314026155: 10:23:46.155 Sun 07 Apr 2013, 192.168.0.254:5060/udp (326 bytes) sent
ACK sip:57#192.168.0.254:5060 SIP/2.0
Via: SIP/2.0/UDP 192.168.0.57:5060;rport;branch=z9hG4bK644461b7
Max-Forwards: 70
To: "Alice" <sip:57#192.168.0.254:5060>;tag=as3f160681
From: "aziz" <sip:157#192.168.0.254>;tag=350164683297
Call-ID: 728007708208#192.168.0.57
CSeq: 2 ACK
User-Agent: mjsip 1.7
Content-Length: 0
-----End-of-message-----

A little late, but often times this is related to codec incompatibilities.
For anyone encountering this issue, they should check whether both sides (server and client) have at least one codes they can negotiate.
From the log posted:
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
It appears that G711 is requested but unavailable on the server side. Hence the server rejects the RTP channel.

I had the same error using a Snom 300 phone to contact an Asterisk server. Turning RTP encryption off on the phone worked for me.
On V7 firmware, this is in: "V7: Identities - RTP Settings(Section): RTP Encryption". Apparently, on V7, RTP encryption is turned on by default: http://wiki.snom.com/wiki/index.php/Settings/user_srtp
I don't know if the root cause is that the Asterisk server is misconfigured (I don't run it), but at least this worked around the problem.

For me, it was my VOIP provider's server-side setting expecting only encrypted connections. I forgot about it after I reverted to plaintext connections in the client.

I encountered this error in Zoiper5 Desktop application. The issue was resolved probably by setting RTCP Feedback-> OFF, previously I used "Compatibility mode", hence it is the most probable cause of 488 error. Also, I have changed the order of codecs to: G.711 mulaw; a-law; GSM FR; G.722 whereas moving OPUS codec to the least preferable spot codecs' order.

Related

Freeswitch outbound calls dropping after about 30 seconds due to ACK timeout [closed]

Closed. This question is not about programming or software development. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 4 months ago.
Improve this question
Issue Description
Freeswitch not sending SIP ACK when call answer event (200 OK) is received from the remote gateway. The gateway repeatedly sends 200 OK for 30 seconds and then drops the call due to a ACK timeout.
This is resulting in all outbound calls through the gateway dropping after 32-33 seconds even though 2-way media is established.
All incoming calls through the same gateway work fine.
Outbound calls to registered extensions also work fine. The extensions are also registering to the Freeswitch over the internet using the external IP of Freeswitch server.
Setup
Freeswitch 1.10.8-dev running on an AWS EC2 instance with an elastic IP.
Variables external_sip_ip and external_rtp_ip are both set to be deduced via STUN.
Remote gateway reached over the internet. Transport used is TCP. SRTP/ZRTP disabled.
acl.conf.xml whitelists the remote gateway IP under "domains".
Security group/Firewall rules allow full communication with remote gateway (0-65353 on both UDP and TCP) for the time being.
Expected behaviour
Outbound calls through the gateway should work seamlessly just like inbound calls through gateway and extension calls. Outbound calls through gateway should not drop after about 30 seconds.
Freeswitch version
1.10.8-dev
Gateway xml
<include>
<gateway name="airtel">
<param name="username" value=""/>
<param name="password" value=""/>
<param name="realm" value="remote.gateway.ip.addr:6060"/>
<param name="proxy" value="remote.gateway.ip.addr:6060;transport=tcp"/>
<param name="from-user" value="+917654321098"/>
<param name="from-domain" value="fs.ext.ip.addr"/>
<param name="register-transport" value="tcp" />
<param name="register" value="false" />
<param name="auth-calls" value="false"/>
<param name="caller-id-in-from" value="true"/>
<param name="vad" value="both"/>
<variables>
<variable name="rtp_secure_media" value="false"/>
</variables>
</gateway>
</include>
Trace logs
INVITE sip:+919876543210#remote.gateway.ip.addr:6060;transport=tcp SIP/2.0
Via: SIP/2.0/TCP fs.ext.ip.addr;rport;branch=z9hG4bKXyZrZU4jZUjve
Max-Forwards: 70
From: <sip:0000000000#fs.ext.ip.addr>;tag=SmjU29t0HXt2g
To: <sip:+919876543210#remote.gateway.ip.addr:6060;transport=tcp>
Call-ID: 0bbd8929-ae0f-123b-08b9-02e5070a49dd
CSeq: 56984975 INVITE
Contact: <sip:gw+airtel#fs.ext.ip.addr:5060;transport=tcp;gw=airtel>
User-Agent: FreeSWITCH-mod_sofia/1.10.8-dev+git~20220427T172338Z~7e2d6384bc~64bit
Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY, PUBLISH, SUBSCRIBE
Supported: timer, path, replaces
Allow-Events: talk, hold, conference, presence, as-feature-event, dialog, line-seize, call-info, sla, include-session-description, presence.winfo, message-summary, refer
Content-Type: application/sdp
Content-Disposition: session
Content-Length: 266
X-HiveName: nithish_kubernetes
X-FS-Support: update_display,send_info
Remote-Party-ID: <sip:0000000000#fs.ext.ip.addr>;party=calling;screen=yes;privacy=off
v=0
o=FreeSWITCH 1663056732 1663056733 IN IP4 fs.ext.ip.addr
s=FreeSWITCH
c=IN IP4 fs.ext.ip.addr
t=0 0
m=audio 20802 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-15
a=ptime:20
SIP/2.0 100 Trying
Via: SIP/2.0/TCP fs.ext.ip.addr;rport=57679;branch=z9hG4bKXyZrZU4jZUjve
From: <sip:0000000000#fs.ext.ip.addr>;tag=SmjU29t0HXt2g
To: <sip:+919876543210#remote.gateway.ip.addr:6060;transport=tcp>
Call-ID: 0bbd8929-ae0f-123b-08b9-02e5070a49dd
CSeq: 56984975 INVITE
Content-Length: 0
SIP/2.0 183 Session Progress
Via: SIP/2.0/TCP fs.ext.ip.addr;rport=57679;branch=z9hG4bKXyZrZU4jZUjve
From: <sip:0000000000#fs.ext.ip.addr>;tag=SmjU29t0HXt2g
To: <sip:+919876543210#remote.gateway.ip.addr:6060;transport=tcp>;tag=007d7ff6a00e45fe15ffbb8ea6137e87
Call-ID: 0bbd8929-ae0f-123b-08b9-02e5070a49dd
CSeq: 56984975 INVITE
Contact: <sip:+919876543210#remote.gateway.ip.addr:17828;transport=TCP>
Supported: replaces
Content-Type: application/sdp
Content-Length: 199
v=0
o=host 321988 321989 IN IP4 remote.gateway.ip.addr
s=-
c=IN IP4 remote.gateway.ip.addr
t=0 0
m=audio 41860 RTP/AVP 0 101
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-11
a=ptime:20
SIP/2.0 200 OK
Via: SIP/2.0/TCP fs.ext.ip.addr;rport=57679;branch=z9hG4bKXyZrZU4jZUjve
From: <sip:0000000000#fs.ext.ip.addr>;tag=SmjU29t0HXt2g
To: <sip:+919876543210#remote.gateway.ip.addr:6060;transport=tcp>;tag=007d7ff6a00e45fe15ffbb8ea6137e87
Call-ID: 0bbd8929-ae0f-123b-08b9-02e5070a49dd
CSeq: 56984975 INVITE
Contact: <sip:+919876543210#remote.gateway.ip.addr:17828;transport=TCP>
Supported: replaces
Allow: INVITE, ACK, CANCEL, BYE, OPTIONS, INFO, UPDATE, NOTIFY, REFER
Content-Type: application/sdp
Content-Length: 199
v=0
o=host 322940 322941 IN IP4 remote.gateway.ip.addr
s=-
c=IN IP4 remote.gateway.ip.addr
t=0 0
m=audio 41860 RTP/AVP 0 101
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-11
a=ptime:20
SIP/2.0 200 OK
Via: SIP/2.0/TCP fs.ext.ip.addr;rport=57679;branch=z9hG4bKXyZrZU4jZUjve
From: <sip:0000000000#fs.ext.ip.addr>;tag=SmjU29t0HXt2g
To: <sip:+919876543210#remote.gateway.ip.addr:6060;transport=tcp>;tag=007d7ff6a00e45fe15ffbb8ea6137e87
Call-ID: 0bbd8929-ae0f-123b-08b9-02e5070a49dd
CSeq: 56984975 INVITE
Contact: <sip:+919876543210#remote.gateway.ip.addr:17828;transport=TCP>
Supported: replaces
Allow: INVITE, ACK, CANCEL, BYE, OPTIONS, INFO, UPDATE, NOTIFY, REFER
Content-Type: application/sdp
Content-Length: 199
v=0
o=host 322940 322941 IN IP4 remote.gateway.ip.addr
s=-
c=IN IP4 remote.gateway.ip.addr
t=0 0
m=audio 41860 RTP/AVP 0 101
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-11
a=ptime:20
SIP/2.0 200 OK
Via: SIP/2.0/TCP fs.ext.ip.addr;rport=57679;branch=z9hG4bKXyZrZU4jZUjve
From: <sip:0000000000#fs.ext.ip.addr>;tag=SmjU29t0HXt2g
To: <sip:+919876543210#remote.gateway.ip.addr:6060;transport=tcp>;tag=007d7ff6a00e45fe15ffbb8ea6137e87
Call-ID: 0bbd8929-ae0f-123b-08b9-02e5070a49dd
CSeq: 56984975 INVITE
Contact: <sip:+919876543210#remote.gateway.ip.addr:17828;transport=TCP>
Supported: replaces
Allow: INVITE, ACK, CANCEL, BYE, OPTIONS, INFO, UPDATE, NOTIFY, REFER
Content-Type: application/sdp
Content-Length: 199
v=0
o=host 322940 322941 IN IP4 remote.gateway.ip.addr
s=-
c=IN IP4 remote.gateway.ip.addr
t=0 0
m=audio 41860 RTP/AVP 0 101
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-11
a=ptime:20
SIP/2.0 200 OK
Via: SIP/2.0/TCP fs.ext.ip.addr;rport=57679;branch=z9hG4bKXyZrZU4jZUjve
From: <sip:0000000000#fs.ext.ip.addr>;tag=SmjU29t0HXt2g
To: <sip:+919876543210#remote.gateway.ip.addr:6060;transport=tcp>;tag=007d7ff6a00e45fe15ffbb8ea6137e87
Call-ID: 0bbd8929-ae0f-123b-08b9-02e5070a49dd
CSeq: 56984975 INVITE
Contact: <sip:+919876543210#remote.gateway.ip.addr:17828;transport=TCP>
Supported: replaces
Allow: INVITE, ACK, CANCEL, BYE, OPTIONS, INFO, UPDATE, NOTIFY, REFER
Content-Type: application/sdp
Content-Length: 199
v=0
o=host 322940 322941 IN IP4 remote.gateway.ip.addr
s=-
c=IN IP4 remote.gateway.ip.addr
t=0 0
m=audio 41860 RTP/AVP 0 101
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-11
a=ptime:20
SIP/2.0 200 OK
Via: SIP/2.0/TCP fs.ext.ip.addr;rport=57679;branch=z9hG4bKXyZrZU4jZUjve
From: <sip:0000000000#fs.ext.ip.addr>;tag=SmjU29t0HXt2g
To: <sip:+919876543210#remote.gateway.ip.addr:6060;transport=tcp>;tag=007d7ff6a00e45fe15ffbb8ea6137e87
Call-ID: 0bbd8929-ae0f-123b-08b9-02e5070a49dd
CSeq: 56984975 INVITE
Contact: <sip:+919876543210#remote.gateway.ip.addr:17828;transport=TCP>
Supported: replaces
Allow: INVITE, ACK, CANCEL, BYE, OPTIONS, INFO, UPDATE, NOTIFY, REFER
Content-Type: application/sdp
Content-Length: 199
v=0
o=host 322940 322941 IN IP4 remote.gateway.ip.addr
s=-
c=IN IP4 remote.gateway.ip.addr
t=0 0
m=audio 41860 RTP/AVP 0 101
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-11
a=ptime:20
SIP/2.0 200 OK
Via: SIP/2.0/TCP fs.ext.ip.addr;rport=57679;branch=z9hG4bKXyZrZU4jZUjve
From: <sip:0000000000#fs.ext.ip.addr>;tag=SmjU29t0HXt2g
To: <sip:+919876543210#remote.gateway.ip.addr:6060;transport=tcp>;tag=007d7ff6a00e45fe15ffbb8ea6137e87
Call-ID: 0bbd8929-ae0f-123b-08b9-02e5070a49dd
CSeq: 56984975 INVITE
Contact: <sip:+919876543210#remote.gateway.ip.addr:17828;transport=TCP>
Supported: replaces
Allow: INVITE, ACK, CANCEL, BYE, OPTIONS, INFO, UPDATE, NOTIFY, REFER
Content-Type: application/sdp
Content-Length: 199
v=0
o=host 322940 322941 IN IP4 remote.gateway.ip.addr
s=-
c=IN IP4 remote.gateway.ip.addr
t=0 0
m=audio 41860 RTP/AVP 0 101
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-11
a=ptime:20
SIP/2.0 200 OK
Via: SIP/2.0/TCP fs.ext.ip.addr;rport=57679;branch=z9hG4bKXyZrZU4jZUjve
From: <sip:0000000000#fs.ext.ip.addr>;tag=SmjU29t0HXt2g
To: <sip:+919876543210#remote.gateway.ip.addr:6060;transport=tcp>;tag=007d7ff6a00e45fe15ffbb8ea6137e87
Call-ID: 0bbd8929-ae0f-123b-08b9-02e5070a49dd
CSeq: 56984975 INVITE
Contact: <sip:+919876543210#remote.gateway.ip.addr:17828;transport=TCP>
Supported: replaces
Allow: INVITE, ACK, CANCEL, BYE, OPTIONS, INFO, UPDATE, NOTIFY, REFER
Content-Type: application/sdp
Content-Length: 199
v=0
o=host 322940 322941 IN IP4 remote.gateway.ip.addr
s=-
c=IN IP4 remote.gateway.ip.addr
t=0 0
m=audio 41860 RTP/AVP 0 101
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-11
a=ptime:20
SIP/2.0 200 OK
Via: SIP/2.0/TCP fs.ext.ip.addr;rport=57679;branch=z9hG4bKXyZrZU4jZUjve
From: <sip:0000000000#fs.ext.ip.addr>;tag=SmjU29t0HXt2g
To: <sip:+919876543210#remote.gateway.ip.addr:6060;transport=tcp>;tag=007d7ff6a00e45fe15ffbb8ea6137e87
Call-ID: 0bbd8929-ae0f-123b-08b9-02e5070a49dd
CSeq: 56984975 INVITE
Contact: <sip:+919876543210#remote.gateway.ip.addr:17828;transport=TCP>
Supported: replaces
Allow: INVITE, ACK, CANCEL, BYE, OPTIONS, INFO, UPDATE, NOTIFY, REFER
Content-Type: application/sdp
Content-Length: 199
v=0
o=host 322940 322941 IN IP4 remote.gateway.ip.addr
s=-
c=IN IP4 remote.gateway.ip.addr
t=0 0
m=audio 41860 RTP/AVP 0 101
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-11
a=ptime:20
BYE sip:gw+airtel#fs.ext.ip.addr:5060;transport=tcp;gw=airtel SIP/2.0
Via: SIP/2.0/TCP remote.gateway.ip.addr:17828;branch=z9hG4bKe8b79e46b92fba58ddd0040c8952552b;rport
From: <sip:+919876543210#remote.gateway.ip.addr:6060;transport=tcp>;tag=007d7ff6a00e45fe15ffbb8ea6137e87
To: <sip:0000000000#fs.ext.ip.addr>;tag=SmjU29t0HXt2g
Call-ID: 0bbd8929-ae0f-123b-08b9-02e5070a49dd
CSeq: 56984976 BYE
Supported: replaces
Max-Forwards: 70
Content-Length: 0
SIP/2.0 200 OK
Via: SIP/2.0/TCP remote.gateway.ip.addr:17828;branch=z9hG4bKe8b79e46b92fba58ddd0040c8952552b;rport=6060
From: <sip:+919876543210#remote.gateway.ip.addr:6060;transport=tcp>;tag=007d7ff6a00e45fe15ffbb8ea6137e87
To: <sip:0000000000#fs.ext.ip.addr>;tag=SmjU29t0HXt2g
Call-ID: 0bbd8929-ae0f-123b-08b9-02e5070a49dd
CSeq: 56984976 BYE
User-Agent: FreeSWITCH-mod_sofia/1.10.8-dev+git~20220427T172338Z~7e2d6384bc~64bit
Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY, PUBLISH, SUBSCRIBE
Supported: timer, path, replaces
Content-Length: 0
Findings from SIP traces
External IP is correctly deduced through STUN and the same is being sent in the SIP messages.
For call through gateway, while the 200 OK for the INVITE is not being acknowledged by Freeswitch, the BYE sent from the remote gateway is being acknowledged.
For call to registered user on softphone, Freeswitch responds with SIP ACK when 200 OK is received for the invite.
Configurations already tried
Uncommenting the line setting param "aggressive-nat-detection" to "true" in the SIP profile did not make any difference.
Uncommenting the line setting param "enable-timer" to "false" in the SIP profile did not make any difference.
Any help or pointers to resolve this issue will be greatly appreciated.
Me and my team managed to fix the issue a couple of weeks ago and everything has been working fine since then. Sharing the details below to help others who face similar problems in the future.
I noticed that ACK timeout was not the only issue my Freeswitch installation faced. There was also no SIP BYE being sent when Freeswitch hangs up the call resulting in the remote end retaining the call. The BYE issue was affecting both inbound and outbound calls. This indicated that Freeswitch was failing to start any new SIP transaction like ACK, BYE etc.
Since the SIP trace enabled by sofia global siptrace on was not showing the ACK being sent, I was initially under the impression that this was a Freeswitch bug. However when I noticed that the SIP trace also did not show BYE being sent even though the call was ending in Freeswitch, it made me think in other directions.
That’s when I discovered that we can enable sofia stack debugging to see error messages within the stack. The command to do so is:
sofia loglevel all 9
Diagnosis
log_snippet.txt
fs_cli now showed that Freeswitch attempted to send the ACK but failed to establish a TCP socket connection with a connection refused error. Since the TCP socket itself was not established, the SIP message was never sent.
This happened since the source port of the 200 OK message was different from the port mentioned in the Contact header. The port in the Contact header is the port the remote gateway got through NAT. It appears that the remote gateway closes the TCP socket after the INVITE transaction ends once it sends a 200 OK. When Freeswitch attempts the next SIP transaction (ACK, BYE etc) on the IP and port advertised in the Contact header, it gets rejected by the remote firewall.
Solution
Rewrite the Contact header. Refer NDLB-connectile-dysfunction
I added the below variable to the gateway xml.
<variable name="sip-force-contact" value="NDLB-connectile-dysfunction"/>
I also defined the same in the vars.xml so that the same is applied for incoming calls too.
<X-PRE-PROCESS cmd="set" data="sip-force-contact=NDLB-connectile-dysfunction"/>
Doing this will make Freeswitch rewrite the Contact header IP and port to the whatever source port the request comes from. In my case, the Contact header gets rewritten to 6060 and thus the newer SIP transactions work fine.

PBX Seems to be Declining (603) All SIP Calls

For a simple home communication system, I've set up some very simple SIP / Extensions. Go easy on me, I'm very new to this system.
For now the only way I've gotten them to work (in testing) is to take down the firewall. Still, I seem to be getting instant 603's with every try from every phone.
When I make a call, this is what it reports:
<--- SIP read from UDP:192.168.1.8:5060 --->
INVITE sip:103#192.168.1.6 SIP/2.0
Via: SIP/2.0/UDP 192.168.1.8:5060;rport;branch=z9hG4bKPj43e20551-6dbc-411b-919a-ab117c06ae05
Max-Forwards: 70
From: <sip:0000FFFF004#192.168.1.6>;tag=12e33b02-c7c1-4b83-9ba4-f08c426ece25
To: <sip:103#192.168.1.6>
Contact: <sip:0000FFFF004#192.168.1.8:5060>
Call-ID: 16962f1e-d2e0-4987-af02-dc765ffa793f
CSeq: 6702 INVITE
Allow: PRACK, SUBSCRIBE, NOTIFY, REFER, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, REGISTER, OPTIONS, MESSAGE
upported: replaces, 100rel
Content-Type: application/sdp
Content-Length: 361
v=0
o=dinosaur 3611940779 0 IN IP4 192.168.1.8
s=sflphone
c=IN IP4 192.168.1.8
t=0 0
m=audio 37600 RTP/AVP 0 3 8 9 110 111 112
a=rtpmap:0 PCMU/8000
a=rtpmap:3 GSM/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:9 G722/8000
a=rtpmap:110 speex/8000
a=rtpmap:111 speex/16000
a=rtpmap:112 speex/32000
a=sendrecv
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-15
<------------->
--- (12 headers 16 lines) ---
Sending to 192.168.1.8:5060 (NAT)
Using INVITE request as basis request - 16962f1e-d2e0-4987-af02-dc765ffa793f
Found peer '0000FFFF004' for '0000FFFF004' from 192.168.1.8:5060
<--- Reliably Transmitting (NAT) to 192.168.1.8:5060 --->
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 192.168.1.8:5060;branch=z9hG4bKPj43e20551-6dbc-411b-919a-ab117c06ae05;received=192.168.1.8;rport=5060
From: <sip:0000FFFF004#192.168.1.6>;tag=12e33b02-c7c1-4b83-9ba4-f08c426ece25
To: <sip:103#192.168.1.6>;tag=as69cdb064
Call-ID: 16962f1e-d2e0-4987-af02-dc765ffa793f
CSeq: 6702 INVITE
Server: Asterisk PBX SVN-branch-1.8-r416150
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
WWW-Authenticate: Digest algorithm=MD5, realm="asterisk", nonce="5572b5df"
Content-Length: 0
<------------>
Scheduling destruction of SIP dialog '16962f1e-d2e0-4987-af02-dc765ffa793f' in 32000 ms (Method: INVITE)
<--- SIP read from UDP:192.168.1.8:5060 --->
ACK sip:103#192.168.1.6 SIP/2.0
Via: SIP/2.0/UDP 192.168.1.8:5060;rport;branch=z9hG4bKPj43e20551-6dbc-411b-919a-ab117c06ae05
Max-Forwards: 70
From: <sip:0000FFFF004#192.168.1.6>;tag=12e33b02-c7c1-4b83-9ba4-f08c426ece25
To: <sip:103#192.168.1.6>;tag=as69cdb064
Call-ID: 16962f1e-d2e0-4987-af02-dc765ffa793f
CSeq: 6702 ACK
Content-Length: 0
<------------->
--- (8 headers 0 lines) ---
<--- SIP read from UDP:192.168.1.8:5060 --->
INVITE sip:103#192.168.1.6 SIP/2.0
Via: SIP/2.0/UDP 192.168.1.8:5060;rport;branch=z9hG4bKPj7504ac55-fcbe-470a-a5c5-2174a0699d0d
Max-Forwards: 70
From: <sip:0000FFFF004#192.168.1.6>;tag=12e33b02-c7c1-4b83-9ba4-f08c426ece25
To: <sip:103#192.168.1.6>
Contact: <sip:0000FFFF004#192.168.1.8:5060>
Call-ID: 16962f1e-d2e0-4987-af02-dc765ffa793f
CSeq: 6703 INVITE
Allow: PRACK, SUBSCRIBE, NOTIFY, REFER, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, REGISTER, OPTIONS, MESSAGE
upported: replaces, 100rel
Authorization: Digest username="0000FFFF004", realm="asterisk", nonce="5572b5df", uri="sip:103#192.168.1.6", response="44810c7fbf0d8a99e34ea07b5e62ee79", algorithm=MD5
Content-Type: application/sdp
Content-Length: 361
v=0
o=dinosaur 3611940779 0 IN IP4 192.168.1.8
s=sflphone
c=IN IP4 192.168.1.8
t=0 0
m=audio 37600 RTP/AVP 0 3 8 9 110 111 112
a=rtpmap:0 PCMU/8000
a=rtpmap:3 GSM/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:9 G722/8000
a=rtpmap:110 speex/8000
a=rtpmap:111 speex/16000
a=rtpmap:112 speex/32000
a=sendrecv
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-15
<------------->
--- (13 headers 16 lines) ---
Sending to 192.168.1.8:5060 (NAT)
Using INVITE request as basis request - 16962f1e-d2e0-4987-af02-dc765ffa793f
Found peer '0000FFFF004' for '0000FFFF004' from 192.168.1.8:5060
== Using SIP RTP CoS mark 5
Found RTP audio format 0
Found RTP audio format 3
Found RTP audio format 8
Found RTP audio format 9
Found RTP audio format 110
Found RTP audio format 111
Found RTP audio format 112
Found audio description format PCMU for ID 0
Found audio description format GSM for ID 3
Found audio description format PCMA for ID 8
Found audio description format G722 for ID 9
Found audio description format speex for ID 110
Found audio description format speex for ID 111
Found unknown media description format speex for ID 112
Found audio description format telephone-event for ID 101
Capabilities: us - 0x100e (gsm|ulaw|alaw|g722), peer - audio=0x20000120e (gsm|ulaw|alaw|speex|speex16|g722)/video=0x0 (nothing)/text=0x0 (nothing), combined - 0x100e (gsm|ulaw|alaw|g722)
Non-codec capabilities (dtmf): us - 0x1 (telephone-event|), peer - 0x1 (telephone-event|), combined - 0x1 (telephone-event|)
Peer audio RTP is at port 192.168.1.8:37600
Looking for 103 in LocalSets (domain 192.168.1.6)
list_route: hop: <sip:0000FFFF004#192.168.1.8:5060>
<--- Transmitting (NAT) to 192.168.1.8:5060 --->
SIP/2.0 100 Trying
Via: SIP/2.0/UDP 192.168.1.8:5060;branch=z9hG4bKPj7504ac55-fcbe-470a-a5c5-2174a0699d0d;received=192.168.1.8;rport=5060
From: <sip:0000FFFF004#192.168.1.6>;tag=12e33b02-c7c1-4b83-9ba4-f08c426ece25
To: <sip:103#192.168.1.6>
Call-ID: 16962f1e-d2e0-4987-af02-dc765ffa793f
CSeq: 6703 INVITE
Server: Asterisk PBX SVN-branch-1.8-r416150
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
Contact: <sip:103#192.168.1.6:5060>
Content-Length: 0
<------------>
-- Executing [103#LocalSets:1] Dial("SIP/0000FFFF004-0000001a", "0000FFFF005") in new stack
== Spawn extension (LocalSets, 103, 1) exited non-zero on 'SIP/0000FFFF004-0000001a'
Scheduling destruction of SIP dialog '16962f1e-d2e0-4987-af02-dc765ffa793f' in 32000 ms (Method: INVITE)
<--- Reliably Transmitting (NAT) to 192.168.1.8:5060 --->
SIP/2.0 603 Declined
Via: SIP/2.0/UDP 192.168.1.8:5060;branch=z9hG4bKPj7504ac55-fcbe-470a-a5c5-2174a0699d0d;received=192.168.1.8;rport=5060
From: <sip:0000FFFF004#192.168.1.6>;tag=12e33b02-c7c1-4b83-9ba4-f08c426ece25
To: <sip:103#192.168.1.6>;tag=as165ecdc9
Call-ID: 16962f1e-d2e0-4987-af02-dc765ffa793f
CSeq: 6703 INVITE
Server: Asterisk PBX SVN-branch-1.8-r416150
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
Content-Length: 0
<------------>
<--- SIP read from UDP:192.168.1.8:5060 --->
ACK sip:103#192.168.1.6 SIP/2.0
Via: SIP/2.0/UDP 192.168.1.8:5060;rport;branch=z9hG4bKPj7504ac55-fcbe-470a-a5c5-2174a0699d0d
Max-Forwards: 70
From: <sip:0000FFFF004#192.168.1.6>;tag=12e33b02-c7c1-4b83-9ba4-f08c426ece25
To: <sip:103#192.168.1.6>;tag=as165ecdc9
Call-ID: 16962f1e-d2e0-4987-af02-dc765ffa793f
CSeq: 6703 ACK
Content-Length: 0
<------------->
--- (8 headers 0 lines) ---
<--- SIP read from UDP:192.168.1.5:63992 --->
<------------->
Really destroying SIP dialog 'cb7123d1-4244-4673-a200-dc851e1c8415' Method: REGISTER
The phones themselves are not set to decline calls, so I can only assume its happening somewhere in Asterisk.
you should write in your dialplan
exten => 103,1,Dial(SIP/0000FFFF005)

Huawei 9000 HD Video Terminal

I'm trying to make Huawei 9000 HD Video Terminal MCU work with asterisk.
Huawei's mcu do not transmit any h264 video and refuses to play the video asterisk sends to it.
Sniffing with wireshark I saw the entire sip negotiation ( relevant traces below ) and the MCU simply rejects the video by putting
m=video 0 RTP/AVP 99
in the 200 OK.
Another issue is that MCU repeatedly sends an INFO request with a proprietary XML body format
Content-Type: application/media_control_hw+xml
Which asterisk replies with 415 Unsupported Media Type. Is this INFO request essential to start video session ?
I could not find any support from Huawei. Apparently it do not have any usable forum.
Any ideas ? Please help.
Asterisk -> MCU ( INVITE )
INVITE sip:mcu#192.168.7.59 SIP/2.0
Via: SIP/2.0/UDP 192.168.7.227:5060;branch=z9hG4bK25a4a145;rport
Max-Forwards: 70
From: "danflu-iphonebria" ;tag=as359f0bce
To:
Contact:
Call-ID: 646e2b425316ccd349b90eba3cf276de#192.168.7.227:5060
CSeq: 102 INVITE
User-Agent: Asterisk PBX SVN-branch-1.8-r402000M
Date: Tue, 29 Oct 2013 19:23:41 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH
Supported: replaces, timer
Content-Type: application/sdp
Content-Length: 348
v=0
o=root 1448364882 1448364882 IN IP4 192.168.7.227
s=Asterisk PBX SVN-branch-1.8-r402000M
c=IN IP4 192.168.7.227
b=CT:384
t=0 0
m=audio 9676 RTP/AVP 8 0 101
a=rtpmap:8 PCMA/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=sendrecv
m=video 8192 RTP/AVP 99
a=rtpmap:99 H264/90000
a=sendrecv
###
MCU -> Asterisk ( 200 OK )
SIP/2.0 200 OK
Via: SIP/2.0/UDP 192.168.7.227:5060;branch=z9hG4bK25a4a145;rport=5060
Call-ID: 646e2b425316ccd349b90eba3cf276de#192.168.7.227:5060
From: "danflu-iphonebria";tag=as359f0bce
To: ;tag=4qda40eh
CSeq: 102 INVITE
Contact: "mcu"
Allow: INVITE,ACK,BYE,CANCEL,UPDATE,OPTIONS,INFO,NOTIFY,PRACK,REFER
User-Agent: Huawei ViewPoint9000/9030-Release_11.2.13.26T
Content-Length: 245
Content-Type: application/sdp
v=0
o=huawei 1 0 IN IP4 192.168.7.59
s=-
c=IN IP4 192.168.7.59
b=CT:384
t=0 0
m=audio 10002 RTP/AVP 8 0 101
a=rtpmap:8 PCMA/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-15
a=sendrecv
*m=video 0 RTP/AVP 99 *
###
MCU -> Asterisk INFO request
INFO sip:danflu-iphonebria#192.168.7.227:5060 SIP/2.0
Via: SIP/2.0/UDP 192.168.7.59:5060;branch=z9hG4bKlc4dje4ajgjh4lpjgjfca2lfj
Call-ID: 646e2b425316ccd349b90eba3cf276de#192.168.7.227:5060
From: ;tag=4qda40eh
To: "danflu-iphonebria";tag=as359f0bce
CSeq: 2 INFO
Contact: "mcu"
Max-Forwards: 70
Content-Length: 455
Content-Type: application/media_control_hw+xml
<?xml version="1.0" encoding="utf-8" ?>
<media_control xmlns="http://www.huawei.com/media-control" version="1.0">
<cap equ_type="term">
<anti_packet_loss>
<protocol>h264
</anti_packet_loss>
<anti_packet_loss2.0>
<protocol>h264
<stream_type>video_amc
</anti_packet_loss2.0>
<cisco_tip_cap>
<stream_type>video_amc
</cisco_tip_cap>
<arq_cap>
<media_type>video
</arq_cap>
</cap>
</media_control>
Disable on asterisk any codec except this one.
Yes, sure, SINGLE!!! VIDEO!!! CODEC IN SDP is essential for setup. MCU just not offer other choices, asterisk say it can't accept MCU's choice.
P.S. this is not programming question, post in admin support or contact vendor.

pjsip sip header configuration

I am using Sip in my ios projects and siphon classes on top of pjsip sdk .
I have no problem with basic configuration and therefore I need to add some custom data to my sip header whenever I make a sip call.
I have the following header format
pjsua_core.c . TX 1123 bytes Request msg INVITE/cseq=31730 (tdta0x92aa400) to UDP xxxxx: 5060:
INVITE sip:xxx9#xxxxxx SIP/2.0
Via: SIP/2.0/UDP xxxxx:xxx;rport;branch=z9hG4bKPjt.fUN05fzpwxbm5zJvjoGSA.bnLvoAHl
Max-Forwards: 70
From: sip:xxxx#xxxxx;tag=d1Ww0T4iQNqygphKlqLQ.iNcYx-Cdsb2
To: sip:xxxx#xxxxxxxx
Contact:
Call-ID: a3zCaQtWPsnKrlbyYtLwwhUQgxnLs8hv
CSeq: 31730 INVITE
Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS
Supported: replaces, 100rel, timer, norefersub
Session-Expires: 1800
Min-SE: 90
User-Agent: Siphon PjSip v2.0.1svn/arm-apple-darwin9
;sdsd: BLABLABLA
Content-Type: application/sdp
Content-Length: 448
v=0
o=- 3563345387 3563345387 IN IP4 192.168.1.3
s=pjmedia
b=AS:84
t=0 0
a=X-nat:0
m=audio 40000 RTP/AVP 98 97 99 104 3 0 8 96
c=IN IP4 192.168.1.3
b=TIAS:64000
a=rtcp:40001 IN IP4 192.168.1.3
a=sendrecv
a=rtpmap:98 speex/16000
a=rtpmap:97 speex/8000
a=rtpmap:99 speex/32000
a=rtpmap:104 iLBC/8000
a=fmtp:104 mode=30
a=rtpmap:3 GSM/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:96 telephone-event/8000
a=fmtp:96 0-15
--end msg--
I want to change the following two lines
From: sip:xxxx#xxxxx;tag=d1Ww0T4iQNqygphKlqLQ.iNcYx-Cdsb2
To: sip:xxxx#xxxxxxxx
to look like this
From: sip:xxxx#xxxxx;tag=d1Ww0T4iQNqygphKlqLQ.iNcYx-Cdsb2;textid=1 ;texfrom=2;textto=4
To: sip:xxxx#xxxxxxxx
just like that.
Kindly, provide some clarity.
pjsip uses pjsua_call_make_call API to make a call. Inside this it creates a dialog with a call to pjsip_dlg_create_uac. You can pass your custom headers to this API. More information here

Failure of SIP Proxy Authentication

I'm developing a SIP user agent application that connects to an Asterisk server and tries to do an outgoing call. I'm using the NIST implementation of the JAIN SIP API.
When the application registers itself, a 401 (Unauthorized) response challenges it with a WWW-Authenticate header. The application inserts the Authorization header into the next REGISTER request. This time Asterisk returns a 200 (OK) response - the registration is successful.
When the application transmits an INVITE request, Asterisk responds with a 407 (Proxy Authentication Required) response. This time the response contains a Proxy-Authenticate header. My application sends an INVITE again, but this time with the Authorization header, upon which Asterisk responds with the same 407 (Proxy Authentication Required) response.
Here are the SIP messages that are transmitted ('>>' indicates outgoing messages; '<<' indicates incoming messages):
>>
REGISTER sip:10.0.84.30:5060 SIP/2.0
Call-ID: acf3c0e9c1338d2c28d9c534ae86cbd8#10.0.85.3
CSeq: 1 REGISTER
From: <sip:301#asterisk>;tag=2B3n8g
To: <sip:301#asterisk>
Via: SIP/2.0/UDP 10.0.85.3:5060;branch=z9hG4bKc7dd178d3d444ccc059a191e700fc8b73230
Max-Forwards: 70
Contact: <sip:10.0.85.3:5060>
Expires: 300
Content-Length: 0
<<
SIP/2.0 100 Trying
Via: SIP/2.0/UDP 10.0.85.3:5060;branch=z9hG4bKc7dd178d3d444ccc059a191e700fc8b73230;received=10.0.85.3
From: <sip:301#asterisk>;tag=2B3n8g
To: <sip:301#asterisk>
Call-ID: acf3c0e9c1338d2c28d9c534ae86cbd8#10.0.85.3
CSeq: 1 REGISTER
User-Agent: Asterisk PBX (switchvox)
Allow: INVITE,ACK,CANCEL,OPTIONS,BYE,REFER,SUBSCRIBE,NOTIFY
Contact: <sip:301#10.0.84.30>
Content-Length: 0
<<
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 10.0.85.3:5060;branch=z9hG4bKc7dd178d3d444ccc059a191e700fc8b73230;received=10.0.85.3
From: <sip:301#asterisk>;tag=2B3n8g
To: <sip:301#asterisk>;tag=as3c458716
Call-ID: acf3c0e9c1338d2c28d9c534ae86cbd8#10.0.85.3
CSeq: 1 REGISTER
User-Agent: Asterisk PBX (switchvox)
Allow: INVITE,ACK,CANCEL,OPTIONS,BYE,REFER,SUBSCRIBE,NOTIFY
Contact: <sip:301#10.0.84.30>
WWW-Authenticate: Digest realm="asterisk",nonce="6fbe5a68"
Content-Length: 0
>>
REGISTER sip:10.0.84.30:5060 SIP/2.0
CSeq: 2 REGISTER
From: <sip:301#asterisk>;tag=2B3n8g
To: <sip:301#asterisk>
Via: SIP/2.0/UDP 10.0.85.3:5060;branch=z9hG4bKffb0be254f93f61fa0dc7ac32b9078a43230
Max-Forwards: 70
Contact: <sip:10.0.85.3:5060>
Expires: 300
Authorization: Digest username="301",realm="asterisk",nonce="6fbe5a68",response="bc7075e8e241a4109dfa24d6ae95e78c",algorithm=MD5,uri="sip:10.0.84.30:5060",nc=00000001
Call-ID: acf3c0e9c1338d2c28d9c534ae86cbd8#10.0.85.3
Content-Length: 0
<<
SIP/2.0 100 Trying
Via: SIP/2.0/UDP 10.0.85.3:5060;branch=z9hG4bKffb0be254f93f61fa0dc7ac32b9078a43230;received=10.0.85.3
From: <sip:301#asterisk>;tag=2B3n8g
To: <sip:301#asterisk>
Call-ID: acf3c0e9c1338d2c28d9c534ae86cbd8#10.0.85.3
CSeq: 2 REGISTER
User-Agent: Asterisk PBX (switchvox)
Allow: INVITE,ACK,CANCEL,OPTIONS,BYE,REFER,SUBSCRIBE,NOTIFY
Contact: <sip:301#10.0.84.30>
Content-Length: 0
<<
SIP/2.0 200 OK
Via: SIP/2.0/UDP 10.0.85.3:5060;branch=z9hG4bKffb0be254f93f61fa0dc7ac32b9078a43230;received=10.0.85.3
From: <sip:301#asterisk>;tag=2B3n8g
To: <sip:301#asterisk>;tag=as3c458716
Call-ID: acf3c0e9c1338d2c28d9c534ae86cbd8#10.0.85.3
CSeq: 2 REGISTER
User-Agent: Asterisk PBX (switchvox)
Allow: INVITE,ACK,CANCEL,OPTIONS,BYE,REFER,SUBSCRIBE,NOTIFY
Expires: 300
Contact: <sip:10.0.85.3:5060>;expires=300
Date: Tue, 03 May 2011 06:42:33 GMT
Content-Length: 0
>>
INVITE sip:302#asterisk SIP/2.0
Call-ID: c20df277bb6f9fb69d83000e5255eb86#10.0.85.3
CSeq: 3 INVITE
From: <sip:301#asterisk>;tag=KOZWxg
To: <sip:302#asterisk>
Via: SIP/2.0/UDP 10.0.85.3:5060;branch=z9hG4bKaa0520efde83907b71d1f76315188c413230
Max-Forwards: 70
Contact: <sip:10.0.85.3:5060>
Route: <sip:10.0.84.30:5060;lr>
Content-Type: application/sdp
Content-Length: 106
>>
v=0
o=- 3513393083 3513393083 IN IP4 10.0.85.3
s=-
c=IN IP4 10.0.85.3
t=0 0
m=audio 40000 RTP/AVP 3
<<
SIP/2.0 407 Proxy Authentication Required
Via: SIP/2.0/UDP 10.0.85.3:5060;branch=z9hG4bKaa0520efde83907b71d1f76315188c413230;received=10.0.85.3
From: <sip:301#asterisk>;tag=KOZWxg
To: <sip:302#asterisk>;tag=as5de9ed83
Call-ID: c20df277bb6f9fb69d83000e5255eb86#10.0.85.3
CSeq: 3 INVITE
User-Agent: Asterisk PBX (switchvox)
Allow: INVITE,ACK,CANCEL,OPTIONS,BYE,REFER,SUBSCRIBE,NOTIFY
Contact: <sip:302#10.0.84.30>
Proxy-Authenticate: Digest realm="asterisk",nonce="74986b64"
Content-Length: 0
>>
INVITE sip:302#asterisk SIP/2.0
CSeq: 4 INVITE
From: <sip:301#asterisk>;tag=2B3n8g
To: <sip:302#asterisk>
Via: SIP/2.0/UDP 10.0.85.3:5060;branch=z9hG4bK86f9dbdff9eeca422fbb67321dd45f7a3230
Max-Forwards: 70
Contact: <sip:10.0.85.3:5060>
Route: <sip:10.0.84.30:5060;lr>
Content-Type: application/sdp
Authorization: Digest username="301",realm="asterisk",nonce="74986b64",response="a08b8d7ce96cae00e7d334e132bf7358",algorithm=MD5,uri="sip:302#asterisk",nc=00000001
Call-ID: acf3c0e9c1338d2c28d9c534ae86cbd8#10.0.85.3
Content-Length: 106
>>
v=0
o=- 3513393083 3513393083 IN IP4 10.0.85.3
s=-
c=IN IP4 10.0.85.3
t=0 0
m=audio 40000 RTP/AVP 3
<<
SIP/2.0 407 Proxy Authentication Required
Via: SIP/2.0/UDP 10.0.85.3:5060;branch=z9hG4bK86f9dbdff9eeca422fbb67321dd45f7a3230;received=10.0.85.3
From: <sip:301#asterisk>;tag=2B3n8g
To: <sip:302#asterisk>;tag=as3c458716
Call-ID: acf3c0e9c1338d2c28d9c534ae86cbd8#10.0.85.3
CSeq: 4 INVITE
User-Agent: Asterisk PBX (switchvox)
Allow: INVITE,ACK,CANCEL,OPTIONS,BYE,REFER,SUBSCRIBE,NOTIFY
Contact: <sip:10.0.85.3:5060>
Proxy-Authenticate: Digest realm="asterisk",nonce="1bd30f50"
Content-Length: 0
The Authorization header is constructed in exactly the same way in both cases (same code that is executed).
I'm using the request's request-URI for "digestURI".
I've tried using a Proxy-Authorization header instead of an Authorization header, but the result is the same.
Can anyone see what I'm doing wrong?
Thanks in advance.
For authenticating to a proxy (in other words you got a 407 Proxy Authentication Required you need a Proxy-Authorization header.
As RFC 2617 says, you construct this in the same way as you would an Authorization header.
You mention using the From URI in your question. RFC 2617 section 3.2.2 says you use the Request-URI (sip:302#asterisk). Watch out for the SIP-specific changes in RFC 3261 section 22.4.
I've solved the problem.
It seems that Asterisk could not associate my second INVITE request to the preceding 407 (Proxy Authentication Required) response, containing the nonce value for the Proxy-Authentication header.
This was because I didn't use the same values for Call-ID and the tag of the From-header for the two INVITE requests. For the second INVITE request, which contains the Proxy-Authentication Header, I've accidentally used the Call-ID and From-header tag values of the first REGISTER request, instead of the first INVITE request.
The INVITE does not yet succeed, though. For the second response I now get 488 (Not acceptable here), but I will try to find out what is wrong now in a different question.
It's s bit strange that your Asterisk server is responding with a 407 I just checked mine and it responds with 401. Asterisk is after all a B2BUA rather than a proxy. I'd recommend trying an Authorization header in the authenticated request rather than Proxy-Authorization as that works with my Asterisk server.
Also you need to use the request URI in the digest and not the From header URI. So in your case it should be uri=sip:302#asterisk.