GSM gateway registration failed

Hello

I make some tests with different GSM Gateway including the GOIP-1I and I faced a major problem in the registration process.
For a strange reason, the GOIP equipment sends too many registration requests with the authentication. This causes the asterisk server to unregister the GOIP equipment.
Please find below the SIP trace I did in asterisk :

<--- SIP read from UDP:132.177.121.25:5064 --->
REGISTER sip:s2.serverss.info SIP/2.0
Via: SIP/2.0/UDP 192.168.1.127:5064;branch=z9hG4bK536538717
From: "goip" <sip:goip@s2.serverss.info>;tag=848351458
To: "goip" <sip:goip@s2.serverss.info>
Call-ID: 1972251384@192.168.1.127
CSeq: 2 REGISTER
Contact: <sip:goip@192.168.1.127:5064>;expires=3600
Max-Forwards: 30
User-Agent: dble
Expires: 3600
Content-Length: 0

<------------->
--- (11 headers 0 lines) ---
Sending to 132.177.121.25:5064 (NAT)

<--- Transmitting (NAT) to 132.177.121.25:5064 --->
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 192.168.1.127:5064;branch=z9hG4bK536538717;received=132.177.121.25;rport=5064
From: "goip" <sip:goip@s2.serverss.info>;tag=848351458
To: "goip" <sip:goip@s2.serverss.info>;tag=as1f97167b
Call-ID: 1972251384@192.168.1.127
CSeq: 2 REGISTER
Server: Asterisk PBX 11.1.1
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH
Supported: replaces, timer
WWW-Authenticate: Digest algorithm=MD5, realm="asterisk", nonce="32233a94"
Content-Length: 0


<------------>
Scheduling destruction of SIP dialog '1972251384@192.168.1.127' in 32000 ms (Method: REGISTER)

<--- SIP read from UDP:132.177.121.25:5064 --->
REGISTER sip:s2.serverss.info SIP/2.0
Via: SIP/2.0/UDP 192.168.1.127:5064;branch=z9hG4bK1868905219
From: "goip" <sip:goip@s2.serverss.info>;tag=848351458
To: "goip" <sip:goip@s2.serverss.info>
Call-ID: 1972251384@192.168.1.127
CSeq: 3 REGISTER
Contact: <sip:goip@192.168.1.127:5064>;expires=3600
Authorization: Digest username="goip", realm="asterisk", nonce="32233a94", uri="sip:s2.serverss.info", response="2edcb0593f49c5dc60952d19a624559f", algorithm=MD5
Max-Forwards: 30
User-Agent: dble
Expires: 3600
Content-Length: 0

<------------->
--- (12 headers 0 lines) ---
Sending to 132.177.121.25:5064 (NAT)
    -- Registered SIP 'goip' at 132.177.121.25:5064
Reliably Transmitting (NAT) to 132.177.121.25:5064:
OPTIONS sip:goip@192.168.1.127:5064 SIP/2.0
Via: SIP/2.0/UDP 91.121.173.173:5060;branch=z9hG4bK72bca53c;rport
Max-Forwards: 70
From: "asterisk" <sip:asterisk@91.121.173.173>;tag=as4e4307e5
To: <sip:goip@192.168.1.127:5064>
Contact: <sip:asterisk@91.121.173.173:5060>
Call-ID: 75c926dc01b7c7c80e30afff233c3a3f@91.121.173.173:5060
CSeq: 102 OPTIONS
User-Agent: Asterisk PBX 11.1.1
Date: Wed, 12 Jun 2013 09:03:24 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH
Supported: replaces, timer
Content-Length: 0


---

<--- Transmitting (NAT) to 132.177.121.25:5064 --->
SIP/2.0 200 OK
Via: SIP/2.0/UDP 192.168.1.127:5064;branch=z9hG4bK1868905219;received=132.177.121.25;rport=5064
From: "goip" <sip:goip@s2.serverss.info>;tag=848351458
To: "goip" <sip:goip@s2.serverss.info>;tag=as1f97167b
Call-ID: 1972251384@192.168.1.127
CSeq: 3 REGISTER
Server: Asterisk PBX 11.1.1
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH
Supported: replaces, timer
Expires: 3600
Contact: <sip:goip@192.168.1.127:5064>;expires=3600
Date: Wed, 12 Jun 2013 09:03:24 GMT
Content-Length: 0


<------------>
Scheduling destruction of SIP dialog '1972251384@192.168.1.127' in 32000 ms (Method: REGISTER)

<--- SIP read from UDP:132.177.121.25:5064 --->
SIP/2.0 200 OK
Via: SIP/2.0/UDP 91.121.173.173:5060;branch=z9hG4bK72bca53c;rport
From: "asterisk" <sip:asterisk@91.121.173.173>;tag=as4e4307e5
To: <sip:goip@192.168.1.127:5064>;tag=162752708
Call-ID: 75c926dc01b7c7c80e30afff233c3a3f@91.121.173.173:5060
CSeq: 102 OPTIONS
Contact: <sip:goip@192.168.1.127:5064>
User-Agent: dble
Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, NOTIFY, REFER, REGISTER, MESSAGE, INFO, SUBSCRIBE
Content-Length: 0

<------------->
--- (10 headers 0 lines) ---
[Jun 12 11:03:24] NOTICE[9647]: chan_sip.c:23200 handle_response_peerpoke: Peer 'goip' is now Reachable. (184ms / 2000ms)
Really destroying SIP dialog '75c926dc01b7c7c80e30afff233c3a3f@91.121.173.173:5060' Method: OPTIONS

<--- SIP read from UDP:132.177.121.25:5064 --->
REGISTER sip:s2.serverss.info SIP/2.0
Via: SIP/2.0/UDP 192.168.1.127:5064;branch=z9hG4bK153444186
From: "goip" <sip:goip@s2.serverss.info>;tag=1016389199
To: "goip" <sip:goip@s2.serverss.info>
Call-ID: 1972251384@192.168.1.127
CSeq: 4 REGISTER
Contact: <sip:goip@192.168.1.127:5064>;expires=0
Authorization: Digest username="goip", realm="asterisk", nonce="32233a94", uri="sip:s2.serverss.info", response="2edcb0593f49c5dc60952d19a624559f", algorithm=MD5
Max-Forwards: 30
User-Agent: dble
Expires: 0
Content-Length: 0

<------------->
--- (12 headers 0 lines) ---
Sending to 132.177.121.25:5064 (NAT)
[Jun 12 11:03:25] NOTICE[9647]: chan_sip.c:16266 check_auth: Correct auth, but based on stale nonce received from '"goip" <sip:goip@s2.serverss.info>;tag=1016389199'

<--- Transmitting (NAT) to 132.177.121.25:5064 --->
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 192.168.1.127:5064;branch=z9hG4bK153444186;received=132.177.121.25;rport=5064
From: "goip" <sip:goip@s2.serverss.info>;tag=1016389199
To: "goip" <sip:goip@s2.serverss.info>;tag=as1f97167b
Call-ID: 1972251384@192.168.1.127
CSeq: 4 REGISTER
Server: Asterisk PBX 11.1.1
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH
Supported: replaces, timer
WWW-Authenticate: Digest algorithm=MD5, realm="asterisk", nonce="4a4e5b7d", stale=true
Content-Length: 0


<------------>
Scheduling destruction of SIP dialog '1972251384@192.168.1.127' in 32000 ms (Method: REGISTER)

<--- SIP read from UDP:132.177.121.25:5064 --->
REGISTER sip:s2.serverss.info SIP/2.0
Via: SIP/2.0/UDP 192.168.1.127:5064;branch=z9hG4bK2101524208
From: "goip" <sip:goip@s2.serverss.info>;tag=1016389199
To: "goip" <sip:goip@s2.serverss.info>
Call-ID: 1972251384@192.168.1.127
CSeq: 5 REGISTER
Contact: <sip:goip@192.168.1.127:5064>;expires=0
Authorization: Digest username="goip", realm="asterisk", nonce="4a4e5b7d", uri="sip:s2.serverss.info", response="88f0aa68dce76064860c723f6e852f92", algorithm=MD5
Max-Forwards: 30
User-Agent: dble
Expires: 0
Content-Length: 0

<------------->
--- (12 headers 0 lines) ---
Sending to 132.177.121.25:5064 (NAT)
    -- Unregistered SIP 'goip'

<--- Transmitting (NAT) to 132.177.121.25:5064 --->
SIP/2.0 200 OK
Via: SIP/2.0/UDP 192.168.1.127:5064;branch=z9hG4bK2101524208;received=132.177.121.25;rport=5064
From: "goip" <sip:goip@s2.serverss.info>;tag=1016389199
To: "goip" <sip:goip@s2.serverss.info>;tag=as1f97167b
Call-ID: 1972251384@192.168.1.127
CSeq: 5 REGISTER
Server: Asterisk PBX 11.1.1
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH
Supported: replaces, timer
Expires: 3600
Contact: <sip:goip@192.168.1.127:5064>;expires=3600
Date: Wed, 12 Jun 2013 09:03:25 GMT
Content-Length: 0


<------------>
Scheduling destruction of SIP dialog '1972251384@192.168.1.127' in 32000 ms (Method: REGISTER)

<--- SIP read from UDP:132.177.121.25:5064 --->
REGISTER sip:s2.serverss.info SIP/2.0
Via: SIP/2.0/UDP 192.168.1.127:5064;branch=z9hG4bK2101524208
From: "goip" <sip:goip@s2.serverss.info>;tag=1016389199
To: "goip" <sip:goip@s2.serverss.info>
Call-ID: 1972251384@192.168.1.127
CSeq: 5 REGISTER
Contact: <sip:goip@192.168.1.127:5064>;expires=0
Authorization: Digest username="goip", realm="asterisk", nonce="4a4e5b7d", uri="sip:s2.serverss.info", response="88f0aa68dce76064860c723f6e852f92", algorithm=MD5
Max-Forwards: 30
User-Agent: dble
Expires: 0
Content-Length: 0

<------------->
--- (12 headers 0 lines) ---
Sending to 132.177.121.25:5064 (NAT)

<--- Transmitting (NAT) to 132.177.121.25:5064 --->
SIP/2.0 200 OK
Via: SIP/2.0/UDP 192.168.1.127:5064;branch=z9hG4bK2101524208;received=132.177.121.25;rport=5064
From: "goip" <sip:goip@s2.serverss.info>;tag=1016389199
To: "goip" <sip:goip@s2.serverss.info>;tag=as1f97167b
Call-ID: 1972251384@192.168.1.127
CSeq: 5 REGISTER
Server: Asterisk PBX 11.1.1
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH
Supported: replaces, timer
Expires: 3600
Contact: <sip:goip@192.168.1.127:5064>;expires=3600
Date: Wed, 12 Jun 2013 09:03:25 GMT
Content-Length: 0

Here is the sip configuration of the GOIP equipment in asterisk :

[goip]
disallow=all
allow=ulaw
canreinvite=no
context=interne
qualify=yes
secret= xxxxxxxxxxxxx
host=dynamic
insecure=port,invite
type=friend
nat=yes
;pedantic=yes  I try yes and no without changes

I try to register the GOIP on 2 different servers with 2 different asterisk version (vers. 1.6.2.13 and 11.1.1) and I always have this problem.
Sometimes it can register without reason, but the most of the time it cannot register in asterisk.

Please let me know if there is a particular parameter to make it work.
Thanks in advance!

It’s not because there are too many, it is because the device is explicitly unregistering.

expires=0 is a request to unregister.

Ok I didn’t know that, so thanks for your explanation.
Is there any workaround which can avoid the sip client to unregister ?
Or is it purely a problem from client-side ?

I would say you need to diagnose this at the remote side.

Note that devices register because they want to be SIP servers. Pure clients can simply authenticate on the INVITE.

do you mean by using

type=peer instead of friend ?

You should normally always use peer rather than friend!

If you had a pure client, that didn’t have a static address, and didn’t register, you would actually use type=user. This is probably academic though. I was really pointing out that client and server are not absolute terms in SIP.

ok, thanks for your information, I’ll search about it and let you know.