#20 Add STUN server support for correct NAT traversing.

v1.1.7
closed
nobody
STUN (1) NAT (1)
5
2013-12-12
2013-11-19
Anonymous
No

Need to add support stun option.
Then we behind the NAT and originate call to some one everything is ok. But then sever try place incoming call on us, it could reach the client, because client talk in this SIP URL wrong(local) port instead of external NAT port.

Maybe this open-source stun client-server app could help.
http://sourceforge.net/projects/stun/

P.S. Sorry for my bad english.

Discussion

  • Anonymous

    Anonymous - 2013-11-19

    Java STUN library (includes a STUN client): JSTUN

    http://jstun.javawi.de/

     
  • Peter Quiring

    Peter Quiring - 2013-11-19

    Most SIP Servers have built in NAT suppport (such as Asterisk).
    JPL already includes a few methods to determine public IP address by using checkip.dyndns.org and connecting to TCP ports to detect public IP. - see SIPClient.java:findlocalhost().
    As for NAT traversal, most routers I deal with use Symmetrical NATing which STUN doesn't support anyways.
    Which SIP servers are you trying to connect to that do NOT support NATing?
    Even my little jPBXlite supports NATing built-in.

    I'm not saying no yet, just want to better understand first.

     
    Last edit: Peter Quiring 2013-11-19
  • Peter Quiring

    Peter Quiring - 2013-11-21

    TURN was added to relay data when the clients are behind Symmetrical firewalls.
    Although Asterisk will relay the data as well.

    ICE = STUN + TURN

    I would like to add this someday...time and motivation willing...

     
  • Anonymous

    Anonymous - 2013-11-24

    Maybe I can interest you in approaching of "someday"? I am very interested in this feature. Please let me know if it is possible.

     
  • Peter Quiring

    Peter Quiring - 2013-11-25

    Ok, I'll start Monday morning.

     
  • Anonymous

    Anonymous - 2013-11-25

    If it is not a joke, then let me know how I can appreciate your efforts?

     
  • Anonymous

    Anonymous - 2013-11-25

    Is PayPal suitable for you?

     
  • Peter Quiring

    Peter Quiring - 2013-11-25

    Not a joke, working on it now. Stun is complete, working on Turn now. Just trying to understand HmacSHA1 right now. Paypal will work fine. I will place donation info in the help box in the next release.

     
  • Anonymous

    Anonymous - 2013-11-25

    Great! I will be very appreciated.

     
  • Peter Quiring

    Peter Quiring - 2013-11-26

    Ok, the code is written, now just need to debug. That could take days... :(

     
  • Anonymous

    Anonymous - 2013-11-26

    I will test it.

     
  • Peter Quiring

    Peter Quiring - 2013-11-27

    Just released version 1.2.0 final.
    Don't use any of the betas, non work over 5mins. Just got the keep alives working now.

    TTYL

     
  • Peter Quiring

    Peter Quiring - 2013-11-27
    • status: open --> closed
     
  • Anonymous

    Anonymous - 2013-12-12

    2013/12/12 21:09:39] Create allDetails:3db087524ca23ae74005351447a7f70b@82.162.180.243:5060
    [2013/12/12 21:09:39] callid:3db087524ca23ae74005351447a7f70b@82.162.180.243:5060
    request=INVITE
    [2013/12/12 21:09:39] SDP.addStream:audio
    [2013/12/12 21:09:39] onInvite : stream=audio,sendrecv,audio1
    [2013/12/12 21:09:39] onInvite : codecs[] = PCMA:8
    [2013/12/12 21:09:39] onInvite : codecs[] = ?:9
    [2013/12/12 21:09:39] onInvite : codecs[] = PCMU:0
    [2013/12/12 21:09:39] onInvite : codecs[] = ?:3
    [2013/12/12 21:09:39] onInvite : codecs[] = iLBC:97
    [2013/12/12 21:09:39] onInvite : codecs[] = telephone-event:101
    [2013/12/12 21:09:39] callid:3db087524ca23ae74005351447a7f70b@82.162.180.243:5060
    issue reply : 180 to : 82.162.180.243
    [2013/12/12 21:09:43] java.lang.Exception: STUN:bad packet:id mismatch
    at javaforce.STUN$Worker.run(STUN.java:578)

    [2013/12/12 21:09:43] STUN:realm=return
    [2013/12/12 21:09:43] STUN:nonce=1386842983:f95e5b1faa4862808786a57c833dc0d9
    [2013/12/12 21:09:43] RTP:TURN:host=95.154.107.226
    [2013/12/12 21:09:43] RTP:TURN:port=49504
    [2013/12/12 21:09:43] java.lang.Exception: STUN:bad packet:id mismatch
    at javaforce.STUN$Worker.run(STUN.java:578)

    [2013/12/12 21:09:43] STUN:realm=return
    [2013/12/12 21:09:43] STUN:nonce=1386842983:f95e5b1faa4862808786a57c833dc0d9
    [2013/12/12 21:09:43] RTP:TURN:host=95.154.107.226
    [2013/12/12 21:09:43] RTP:TURN:port=49505
    [2013/12/12 21:09:43] RTP:localport=32768
    [2013/12/12 21:09:43] java.lang.Exception: STUN:bad packet:id mismatch
    at javaforce.STUN$Worker.run(STUN.java:578)

    [2013/12/12 21:09:43] STUN:realm=return
    [2013/12/12 21:09:43] STUN:nonce=1386842983:f95e5b1faa4862808786a57c833dc0d9
    [2013/12/12 21:09:43] RTP:TURN:host=95.154.107.226
    [2013/12/12 21:09:43] RTP:TURN:port=49506
    [2013/12/12 21:09:43] java.lang.Exception: STUN:bad packet:id mismatch
    at javaforce.STUN$Worker.run(STUN.java:578)

    [2013/12/12 21:09:43] STUN:realm=return
    [2013/12/12 21:09:43] STUN:nonce=1386842983:f95e5b1faa4862808786a57c833dc0d9
    [2013/12/12 21:09:43] RTP:TURN:host=95.154.107.226
    [2013/12/12 21:09:43] RTP:TURN:port=49507
    [2013/12/12 21:09:43] RTP:localport=32770
    [2013/12/12 21:09:43] SDP.addStream:audio
    [2013/12/12 21:09:43] RTPChannel.start() : localhost:49504 remote=82.162.180.243:46910
    [2013/12/12 21:09:43] codec = g711a
    [2013/12/12 21:09:43] callid:3db087524ca23ae74005351447a7f70b@82.162.180.243:5060
    issue reply : 200 to : 82.162.180.243
    [2013/12/12 21:09:43] callid:3db087524ca23ae74005351447a7f70b@82.162.180.243:5060
    request=ACK
    [2013/12/12 21:09:46] callid:3db087524ca23ae74005351447a7f70b@82.162.180.243:5060
    request=BYE
    [2013/12/12 21:09:46] callid:3db087524ca23ae74005351447a7f70b@82.162.180.243:5060
    issue reply : 200 to : 82.162.180.243

     
  • Anonymous

    Anonymous - 2013-12-12

    Why is "STUN:bad packet:id mismatch" ?
    and we cannot establish incoming voice connection.
    Outgoing goes perfectly.

     
  • Anonymous

    Anonymous - 2013-12-12

    I fogot tel versions
    Java Plug-in 10.45.2.18
    Using JRE version 1.7.0_45-b18
    jPhoneLite/1.4.0

     
  • Peter Quiring

    Peter Quiring - 2013-12-12

    Opps, I added a requestPublicIP in javaforce.voip.RTP when it's not needed and I make another request immediately without waiting for the reply which then causes those mismatch id responses. It was a quick change I added in 1.4.0. Either way though, it's harmless. The TURN request should still work and looking at your log it's not. I can see it attempts 4 times and then gives up. Make sure in your reTurn config you have the following:
    TurnAddress = {your_real_ip}
    LongTermAuthUsername = {user_id}
    LongTermAuthPassword = {password}
    Without these settings it will not work. Then make sure you have the same user_id/password used in jPhoneLite under the Topology tab.
    The default settings in reTurn omit the LongTerm values.

    Do you see a "RTP init failed" in jPhoneLite when attempting a call? That should indicate a failed TURN request.

     
    Last edit: Peter Quiring 2013-12-12
  • Peter Quiring

    Peter Quiring - 2013-12-12

    Actually, I think your username/password are fine. Otherwise I would see a "Turn failed" exception. There would be 4 requests, 2 for audio, and 2 for video.
    Let me do some tests.

     
  • Peter Quiring

    Peter Quiring - 2013-12-12

    Everything tested fine for me while using STUN/TURN. What happens when an inbound call comes in? Does the phone ring? Do you get an error code? I think your router may have SIP ALG and is interfering with your phone. Try connecting directly to internet and see if problem persists (either without your router or use a DMZ)

     

Anonymous
Anonymous

Cancel  Add attachments