Grandstream Handy Tone 386 problem with Asterisk


#1

I’m experimenting with a Handy Tone 386 ATA as a device to make and receive calls through the Asterisk PBX and the traditional PBX at the company. We’re using Asterisk 1.2.5 on Fedora Core 4 which is woring perfectly with X-Lite soft phones. With the handy Tone 386 ATA everything works perfectly except receiving external phone calls. In other words, I can:

a) make calls to other extensions
b) receive calls from other extensions
c) make calls to any PSTN phone

When I receive a call from a PSTN, what happens is that I hear noise instead of the correct audios stream. This only happens on the extension when it uses the ATA and only after the connection is made to the extension, not when Asterisk answers (background greeting and “dial the extension of the party…”). To me this looks like a codec conversion problem but I can’t find the right combination.

This is a fragment of the debug log for calls with noise:

Mar 24 18:39:02 DEBUG[6445] chan_sip.c: Acked pending invite 102
Mar 24 18:39:02 DEBUG[6445] chan_sip.c: Stopping retransmission on ‘0d631de12b8fc73b7b31e848342417cf@10.1.9.1’ of Request 102: Match Found
Mar 24 18:39:02 DEBUG[6445] chan_sip.c: Oooh, we need to change our formats since our peer supports only 0x400 (ilbc) and not 0x4 (ulaw)
Mar 24 18:39:02 DEBUG[6445] chan_sip.c: build_route: Contact hop: sip:miguel@10.1.9.90
Mar 24 18:39:02 VERBOSE[6499] logger.c: – SIP/miguelk-25f4 answered SIP/company-a347
Mar 24 18:39:02 DEBUG[6499] channel.c: Scheduling timer at 0 sample intervals
Mar 24 18:39:02 VERBOSE[6499] logger.c: – Attempting native bridge of SIP/company-a347 and SIP/miguel-25f4
Mar 24 18:39:08 DEBUG[6499] channel.c: Didn’t get a frame from channel: SIP/miguel-25f4
Mar 24 18:39:08 DEBUG[6499] channel.c: Bridge stops bridging channels SIP/company-a347 and SIP/miguel-25f4

Mar 24 18:39:08 DEBUG[6499] chan_sip.c: update_call_counter(miguel) - decrement call limit counter

This is a fragment of a call (extension to extension) that works perfectly:

Mar 24 18:47:35 DEBUG[6931] chan_sip.c: Acked pending invite 102
Mar 24 18:47:35 DEBUG[6931] chan_sip.c: Stopping retransmission on ‘24ad8e535f22eb30218cfe3a30085b1d@10.1.9.1’ of Request 102: Match Found
Mar 24 18:47:35 DEBUG[6931] chan_sip.c: build_route: Contact hop: sip:miguel@10.1.9.90
Mar 24 18:47:35 VERBOSE[6959] logger.c: – SIP/miguel-4726 answered SIP/rita-749b
Mar 24 18:47:35 VERBOSE[6959] logger.c: – Attempting native bridge of SIP/rita-749b and SIP/miguel-4726
Mar 24 18:47:35 DEBUG[6931] chan_sip.c: Stopping retransmission on ‘1B2C4209-E646-44C7-820C-C4456348C6E8@10.1.9.30’ of Response 1784: Match Found
Mar 24 18:47:35 DEBUG[6959] chan_sip.c: Oooh, format changed to 2
Mar 24 18:47:40 DEBUG[6959] channel.c: Didn’t get a frame from channel: SIP/ritan-749b
Mar 24 18:47:40 DEBUG[6959] channel.c: Bridge stops bridging channels SIP/rita-749b and SIP/miguel-4726
Mar 24 18:47:40 DEBUG[6959] chan_sip.c: update_call_counter(miguel) - decrement call limit counter

The difference is in the line (in the first log) about the peer (I assume this means the sip server my voip provider offers) not supporting ulaw.

The output from the console about these peers looks like this:

poirotCLI> sip show peer miguel
poirot
CLI>

  • Name : miguel
    Secret :
    MD5Secret :
    Context : internos
    Subscr.Cont. :
    Language :
    AMA flags : Unknown
    CallingPres : Presentation Allowed, Not Screened
    Callgroup :
    Pickupgroup :
    Mailbox :
    VM Extension : asterisk
    LastMsgsSent : -1
    Call limit : 0
    Dynamic : Yes
    Callerid : “Miguel” <>
    Expire : 2
    Insecure : no
    Nat : Always
    ACL : No
    CanReinvite : No
    PromiscRedir : No
    User=Phone : No
    Trust RPID : No
    Send RPID : No
    DTMFmode : rfc2833
    LastMsg : 0
    ToHost :
    Addr->IP : 10.1.9.90 Port 5060
    Defaddr->IP : 0.0.0.0 Port 5060
    Def. Username: miguel
    SIP Options : (none)
    Codecs : 0x40e (gsm|ulaw|alaw|ilbc)
    Codec Order : (ilbc,alaw,ulaw,gsm)
    Status : OK (10 ms)
    Useragent :
    Reg. Contact : sip:miguel@10.1.9.90

poirotCLI> sip show peer vono
poirot
CLI>

  • Name : vono
    Secret :
    MD5Secret :
    Context : vono-in
    Subscr.Cont. :
    Language :
    AMA flags : Unknown
    CallingPres : Presentation Allowed, Not Screened
    FromUser : company
    FromDomain : vono.net.br
    Callgroup :
    Pickupgroup :
    Mailbox :
    VM Extension : asterisk
    LastMsgsSent : -1
    Call limit : 0
    Dynamic : No
    Callerid : “Company” <>
    Expire : -1
    Insecure : port,invite
    Nat : Always
    ACL : No
    CanReinvite : No
    PromiscRedir : No
    User=Phone : No
    Trust RPID : No
    Send RPID : No
    DTMFmode : rfc2833
    LastMsg : 0
    ToHost : vono.net.br
    Addr->IP : 200.146.165.79 Port 5060
    Defaddr->IP : 0.0.0.0 Port 0
    Def. Username: ktexlogin
    SIP Options : (none)
    Codecs : 0x40e (gsm|ulaw|alaw|ilbc)
    Codec Order : (ilbc,alaw,ulaw,gsm)
    Status : OK (158 ms)
    Useragent :
    Reg. Contact :

The FXS port on the Handy Tone has this codec preference order defined:

PCMU
PCMA
iLBC
G726-32
G729
iLBC

I would appreciate any clues about how to configure the Handy Tone 386 and/or Asterisk for this situation.


#2

In case this is of use to anyone with a smimilar problem, I found the solution by ordering the codecs in the same order in my sip.conf file for the peer I’m using to match the order set in the ATA. So in the case above I now have this fragment in sip.conf:

[general]
allow=all

[vono]
type=peer
insecure=very
qualify=yes
port=5060 ;sem isso nao pode fazer ligacao para fora
nat=yes
dtmfmode=rfc2833
disallow=all
allow=ulaw
allow=alaw
allow=ilbc
allow=gsm
context=vono-in
canreinvite=no

I think that the order should not really make a difference in conversion. Maybe this is a problem with version 1.2.5.