Asterisk 13.6.0/The Simplest TCP Configuration Does Not Work

Home » Asterisk Users » Asterisk 13.6.0/The Simplest TCP Configuration Does Not Work
Asterisk Users 25 Comments

This question was asked by Chirag on March 4 2015 earlier, but I am following exactly the same procedure here and I cannot even get my clients to register on Asterisk.

Here’s my PJSIP.conf:

[transport-tcp]
type=transport protocol=tcp bind=0.0.0.0:5061

[endpoint_internal](!)
type=endpoint context=from-internal disallow=all allow=!all,ulaw direct_media=no rtp_symmetric=yes message_context=text-context

[auth_userpass](!)
type=auth auth_type=userpass

[aor_dynamic](!)
type=aor max_contacts=1
remove_existing=yes

;;; Configuration for user 99999999

I used basically exactly the same procedure for UDP based registration and it works just fine.

Any help is appreciated. The specific error I see on the CLI is:

Connected to Asterisk 13.6.0 currently running on … (pid = 30046)
*CLI> pjsip set logger on PJSIP Logging enabled
[Feb 15 18:28:12] WARNING[30075]: pjsip:0 : tsx0x7f14b0003 .Temporary failure in sending Request msg OPTIONS/cseqR002 (tdta0x7f14b0001470), will try next server: Unsupported transport (PJSIP_EUNSUPTRANSPORT)
[Feb 15 18:28:12] WARNING[30075]: pjsip:0 : tsx0x7f14b0003 .Temporary failure in sending Request msg OPTIONS/cseqR002 (tdta0x7f14b0001470), will try next server: Unsupported transport (PJSIP_EUNSUPTRANSPORT)
[Feb 15 18:28:12] WARNING[30075]: pjsip:0 : tsx0x7f14b0003 .Temporary failure in sending Request msg OPTIONS/cseqR002 (tdta0x7f14b0001470), will try next server: Unsupported transport (PJSIP_EUNSUPTRANSPORT)
[Feb 15 18:28:12] WARNING[30075]: pjsip:0 : tsx0x7f14b0003 .Failed to send Request msg OPTIONS/cseqR002 (tdta0x7f14b0001470)! err1060
(Unsupported transport (PJSIP_EUNSUPTRANSPORT))
*CLI> core set debug 99
Core debug was OFF and is now 99.
[Feb 15 18:28:27] WARNING[30133]: pjsip:0 : tsx0x7f14b4003 .Temporary failure in sending Request msg OPTIONS/cseqI786 (tdta0x7f14b40014f0), will try next server: Unsupported transport (PJSIP_EUNSUPTRANSPORT)
[Feb 15 18:28:27] WARNING[30133]: pjsip:0 : tsx0x7f14b4003 .Temporary failure in sending Request msg OPTIONS/cseqI786 (tdta0x7f14b40014f0), will try next server: Unsupported transport (PJSIP_EUNSUPTRANSPORT)
[Feb 15 18:28:27] WARNING[30133]: pjsip:0 : tsx0x7f14b4003 .Temporary failure in sending Request msg OPTIONS/cseqI786 (tdta0x7f14b40014f0), will try next server: Unsupported transport (PJSIP_EUNSUPTRANSPORT)
[Feb 15 18:28:27] WARNING[30133]: pjsip:0 : tsx0x7f14b4003 .Failed to send Request msg OPTIONS/cseqI786 (tdta0x7f14b40014f0)! err1060
(Unsupported transport (PJSIP_EUNSUPTRANSPORT))

25 thoughts on - Asterisk 13.6.0/The Simplest TCP Configuration Does Not Work

  • Sonny Rajagopalan wrote:

    This will happen if the URI added does not contain ;transport=tcp which informs things to use TCP. If the device registering doesn’t do this then it will try to use a UDP transport instead, if not available then it will fail.

    What is the REGISTER from the device?

  • Thanks for the mighty quick response, Joshua!

    I am using Zoiper on Linux softclient:
    REGISTER sip:;transport=TCP SIP/2.0

    Changed the port back to 5060.

  • Sonny Rajagopalan wrote:

    That’s the request URI, not the Contact header. The Contact contains the URI that the server should dial to reach the client. The full message would be useful.

    Cheers,

  • Does this help:

    Session Initiation Protocol (REGISTER)
    Request-Line: REGISTER sip:1.2.3.4;transport=TCP SIP/2.0
    Method: REGISTER
    Request-URI: sip:1.2.3.4;transport=TCP
    Request-URI Host Part: 1.2.3.4
    [Resent Packet: False]
    Message Header
    Via: SIP/2.0/TCP 192.168.1.15:47053
    ;branch=z9hG4bK-d8754z-5e3d9f441f1de1d3-1—d8754z-;rport;transport=TCP
    Transport: TCP
    Sent-by Address: 192.168.1.15
    Sent-by port: 47053
    Branch: z9hG4bK-d8754z-5e3d9f441f1de1d3-1—d8754z-
    RPort: rport
    transport=TCP
    Max-Forwards: 70
    Contact:

  • Sonny Rajagopalan wrote:

    Yes, the transport parameter is in the Contact header so it’s interesting it didn’t work. If you use pjsip show contacts what is the contact for the AOR?

  • Nope, there are no contacts to show that pertain to these endpoints (only my SIP trunks show up).

  • I can confirm that the server is receiving the SIP request, but simply doesn’t do anything with it (log from the server below). Does this have anything to do with how PJSIP was compiled or configured?:

    Session Initiation Protocol (REGISTER)
    Request-Line: REGISTER sip:11.12.13.14 SIP/2.0
    Method: REGISTER
    Request-URI: sip:11.12.13.14
    Request-URI Host Part: 11.12.13.14
    [Resent Packet: False]
    Message Header
    Via: SIP/2.0/TCP 192.168.1.16:54402
    ;rport;branch=z9hG4bKPjpaCDxnhZT22z-O183o5uZzMHNwTNrpkl;alias
    Transport: TCP
    Sent-by Address: 192.168.1.16
    Sent-by port: 54402
    RPort: rport
    Branch: z9hG4bKPjpaCDxnhZT22z-O183o5uZzMHNwTNrpkl
    alias
    Route:
    Route URI: sip:11.12.13.14;transport=tcp;lr
    Route Host Part: 11.12.13.14
    Route URI parameter: transport=tcp
    Route URI parameter: lr
    Max-Forwards: 70
    From:
    SIP to address: sip:987654321@11.12.13.14
    SIP to address User Part: 987654321
    SIP to address Host Part: 11.12.13.14
    Call-ID: 8NDmEFaT2lmQRMUBf77UrRKRBIc3cT0h
    CSeq: 29457 REGISTER
    Sequence Number: 29457
    Method: REGISTER
    Supported: outbound, path
    Contact: ;reg-id=1;+sip.instance=”
    Contact URI: sip:987654321@192.168.1.16:54402;transport=TCP;ob
    Contact URI User Part: 987654321
    Contact URI Host Part: 192.168.1.16
    Contact URI Host Port: 54402
    Contact URI parameter: transport=TCP
    Contact URI parameter: ob
    Contact parameter: reg-id=1
    Contact parameter:
    +sip.instance=”“\r\n
    Expires: 900
    Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS
    Content-Length: 0

  • Sonny Rajagopalan wrote:

    TCP support is enabled in PJSIP by default. If you do “pjsip set logger on” does the message show up? What is the COMPLETE console output when a client connects? We have tests which cover TCP and they are working, so it’s likely something environment specific.

  • I receive a TCP ack back from that port (5060; owned by Asterisk)
    –confirmed by wireshark on the Asterisk server.

    What else should I be looking for? This is on a machine on AWS that was running a UDP based Asterisk fine (I did not make ANY other change other than changing protocol=tcp). I also tried a fresh build with protocol=tcp. Did not work.

  • Sonny Rajagopalan wrote:

    That’s from Wireshark, but what is Asterisk seeing? If Asterisk doesn’t show the connection or the traffic then something else is up (firewall, etc). Try to isolate things further, start from Asterisk itself.

  • Is there a specific place where I can set logger to log incoming TCP
    segments from L4?

    $ netstat -tulpn | grep asterisk | grep LISTEN:

    tcp 0 0 0.0.0.0:8088 0.0.0.0:* LISTEN
    10313/asterisk tcp 0 0 0.0.0.0:5060 0.0.0.0:* LISTEN
    10313/asterisk tcp 0 0 0.0.0.0:2000 0.0.0.0:* LISTEN
    10313/asterisk

  • Sonny Rajagopalan wrote:

    “pjsip set logger on” will output all incoming and outgoing SIP traffic for all transports in PJSIP, and when a connection is established it is logged to the console.

  • Sorry, I was not being very clear, Joshua, and thanks for your patience with this issue.

    I had set pjsip set logger on and core set debug 99. See absolutely zilch on asterisk CLI. Or in /var/log/asterisk/messages. If the messages are not reaching Asterisk, what could be the issue? I am a little perplexed as to why Asterisk wouldn’t consume those TCP segments; the port is owned by Asterisk.

  • Sonny Rajagopalan wrote:

    Then it’s likely something outside the scope of Asterisk, if the connection (and messages) don’t even seem to be reaching Asterisk at all. You could try to just telnet to it and see if you get a connection message on the Asterisk CLI. Do it from the machine itself and then outside. If it works from the machine itself but not outside, then you’ve narrowed it down more.

  • OK. I will report with my findings. It appears increasingly likely that I
    have done something very silly on my side. It is a little perplexing that the EXACT setup (on the same machine) worked for UDP …

  • OK. Let me ask this. Is anything else necessary, except choosing TCP as the preferred protocol on the client, to make TCP w Asterisk work? At the moment, I have only changed one line in pjsip.conf from my working UDP
    setup:

    [transport-tcp]
    type=transport protocol=tcp ; <--------------- only this line was changed.

  • Yes, it is enabled on port 5060. I do receive a TCP ACK back from the server, so I know the TCP segment is received at the server hosting the Asterisk build.

  • I made some progress. The first thing I have realized is that it is my Twilio configuration in pjsip_wizard.conf that was killing me. I have since removed that entire file from /etc/asterisk and I am able to make
    “from-internal” context calls (i.e., calls that do not leave the VoIP
    island).

    Here’s what I have right now in pjsip_wizard.conf (again, I have removed it from /etc/asterisk/ because Asterisk won’t even work for “from-internal”
    calls with the conf in /etc/asterisk)

    [twilio-siptrunk]
    type = wizard sends_auth = yes sends_registrations = no remote_hosts = silly.pstn.twilio.com outbound_auth/username = username outbound_auth/password = sillypassword endpoint/context = from-external ;;; change later endpoint/disallow = all ;;; change later endpoint/allow = ulaw ;;; change later aor/qualify_frequency = 15

    What should I change/add/modify above to make Asterisk and Twilio work with TCP? Note that I do not have to trigger a use of the twilio sip trunk for my Asterisk daemon to not work for TCP. If I have the pjsip_wizard in
    /etc/asterisk, it does not work for _any_ call, regardless of whether or not the call should use the Twilio SIP trunk.

    (again, the same asterisk configuration on the same machine connected to the same twilio SIP trunk worked for UDP)

    If anyone knows the trick to make pjsip_wizard.conf work with twilio, I
    would very much appreciate any insight…

    Thanks, Sonny.

  • Wow. Incredible. That worked. The backslash is important there; I kept trying with no backslash and followed the instructions in pjsip_wizard.conf.sample (in configs/samples) and it says we have to say

    transport=tcp ; the only example however talks about ipv4.

    Is this documented somewhere and I just missed it??

    So, let me sum the issues and their solutions:

    (a) Inside/from-internal calling. Only need transport=tcp in pjsip.conf. No need to update every SIP (user) endpoint’s transport, though that did not disrupt anything.
    (b) For pjsip_wizard configuration, add the transport into the remote_hosts line like so noting that the backslash is important otherwise the transport part of the line is a comment!

    remote_hosts = silly.pstn.twilio.com​\;transport=tcp

    Simple errors, but vexing, vexing, vexing issues.

    Thanks, George, and thanks Joshua, for your time!

    On Wed, Feb 17, 2016 at 12:43 PM, George Joseph

  • One thing to be aware of…​

    There is currently a PJSIP bug when using TCP and TLS that shows up if you explicitly set transport= on an endpoint (or in the wizard). It’s best to leave transport unset and let PJSIP determine the transport from the ;transport= parameter of the URI.

    From a wizard perspective, if you have lots of TCP or TLS endpoints, use a template like so…

    [tcp-template](!)
    server_uri_pattern = sip:${REMOTE_HOST}\;transport=TCP
    client_uri_pattern = sip:${REMOTE_HOST}\;transport=TCP
    contact_pattern = sip:${REMOTE_HOST}\;transport=TCP

    [tls-template](!)
    server_uri_pattern = sips:${REMOTE_HOST}\;transport=TLS
    client_uri_pattern = sips:${REMOTE_HOST}\;transport=TLS
    contact_pattern = sips:${REMOTE_HOST}\;transport=TLS

    [tcp-provider](tcp-template]
    remote_hosts = my.provider.net

    Let me know if the wiki can use some clarification. I haven’t updated it in a while.

  • George,

    May I propose we improve the documentation on the Asterisk Wiki? I thought I would have spent far less time here (though you folks have been mightily helpful, and thanks again!) should the documentation for the TCP transport be improved in both the Wiki and specifically, in
    ${ASTERISK_HOME}/configs/samples/, bundled as part of the code. I want to see Asterisk as a product succeed (even more) and Asterisk in its new version succeed wildly.

    I don’t know if you folks allow outside developers to pitch in, but depending on a number of factors, I might contribute to https://gerrit.asterisk.org/ if that is within Asterisk’s policy. Again, depending on a number of factors, including legal.

    Here, specifically, is the list of improvements I propose:

    (a)