Realtime sip + extensions with mysql

I’ve configured realtime with asterisk 1.2.9.1 , asterisk-addons 1.2.3 and mysql 4.1.13.
If I run the command " realtime load sipusers name olucp ", I see asterisk can lookup the SIPUSERS just fine.

               Column Name  Column Value
      --------------------  --------------------
                        id  1
                      name  olucp
                  callerid  "Luc Pijpers" <682>
               canreinvite  no
                   context  realtime_sip
               fullcontact  olucp
                      host  dynamic
                  insecure  very
                       nat  no
                      port  5060
                    secret  olucp
                      type  friend
                  username  olucp
                  disallow  all
                     allow  gsm
                     allow  ulaw
                     allow  alaw
                regseconds  0
            cancallforward  yes

Still my SIPphone (Grandstream GXP-2000) can 't regiser. In the debug I see the message :
NOTICE[28110]: chan_sip.c:11043 handle_request_register: Registration from ‘sip:olucp@10.65.1.47:5060’ failed for ‘10.65.1.46’ - Username/auth name mismatch

If I configure the settings directly exactly the same in sip.conf, the phone registers without a problem.

What 's rather strange is that asterisk never queries mysql for the sipusers or sippeers. Not when starting, neighter when the sipphone is trying to register. Only when I explicit do the command " realtime load sipusers name olucp ", I see the following lines comming into mysqld.log.

What could be wrong ?

Oh forgot the logging lines of mysqld.log :

060802 10:12:23 165 Init DB asterisk
165 Query SELECT * FROM sip_buddies WHERE name = ‘olucp’

Asterisk has some problem with NAT IP. unless your server and sip client are in the same subnet, or it will suffer this. you need the stun server to handle this if you insist using the NAT IP.

i’d never use STUN with Asterisk, indeed there are ITSPs out there that strongly discourage you from doing so.

i’ve SIP clients on my system that are behind NAT (as is my Asterisk box) and with externip= set, and the appropriate port forwards in place, i’ve yet to have a problem with registration, calling or audio.