Skaraluk has asked for the wisdom of the Perl Monks concerning the following question:

Hi everyone, I'm using Net::SIP::Simple to call to an ip-phone in my network. It does all fine until it get to the 'INVITE' part, then it returns an error '488 Not Acceptable Here' and I don't know what is wrong here, I must accept that is my first time working with phones so I don't understand some things, anyway here is the code I'm using:

#!/usr/bin/perl use IO::Socket::INET; use Net::SIP::Leg; use Net::SIP::Simple; use Net::SIP::Simple::Call; use Net::SIP::Simple::RTP; use Net::SIP::Debug qw( Net::SIP*=2 Registrar=1 ); Net::SIP::Debug->level(2); $| = 1; my $ip_me = 'xxx.xxx.xx.xx'; #server executing the code my $ip_pbx = 'yyy.yyy.yy.yy'; #asterisk my $ip_to = 'zzz.zzz.zz.zzz'; #phone where I'm calling to # create new socket and leg print 'CREATING SOCKET AND LEG... '; my $sock_tel_1 = IO::Socket::INET->new(LocalAddr => $ip_me, PeerAddr = +> $ip_pbx, PeerPort => '5060', Proto => 'udp') or die "Can't bind : $ +@\n"; my $leg_tel_1 = Net::SIP::Leg->new( sock => $sock_tel_1); print 'OK'.$/; # create new rtp print 'CREATING RTP... '; my $echo_10 = Net::SIP::Simple->rtp( 'media_recv_echo', 'output.pcmu-8 +000' ); print 'OK'.$/; # create new agent print 'CREATING AGENT... '; my $ua = Net::SIP::Simple->new( registrar => $ip_pbx, #domain => 'netpro.cl', domain => $ip_pbx, from => 'devel', leg => $leg_tel_1, auth => ['user','password'] #user and password provided in the ast +erisk server ); print $ua->error.' '; print 'OK'.$/; # Register agent my $err = ''; print 'TRY TO REGISTER... '.$/; $ua->register(); $err = $ua->error; if ($err ne ''){ print $err.$/; } print 'OK'.$/; # Invite other party, send anncouncement once connected print 'SEND INVITE... '.$/; $ua->invite( $ip_to, init_media => $echo_10); $err = $ua->error; if ($err ne ''){ print $err.$/; } print 'OK'.$/; $ua->loop;


Here is the output:

CREATING SOCKET AND LEG... OK CREATING RTP... OK CREATING AGENT... OK TRY TO REGISTER... 1285608699.1157 DEBUG:<2> Net::SIP::Leg::deliver[330]: delivery from x +xx.xxx.xx.xx:43289 to udp:yyy.yyy.yy.yy:5060 OK: 1285608699.1157 DEBUG:<2> REQ REGISTER sip:yyy.yyy.yy.yy 1285608699.1178 DEBUG:<2> Net::SIP::Leg::receive[421]: received on xxx +.xxx.xx.xx:43289 from yyy.yyy.yy.yy:5060 packet 1285608699.1178 DEBUG:<2> RESP 100 'Trying' 1285608699.1202 DEBUG:<2> Net::SIP::Leg::receive[421]: received on xxx +.xxx.xx.xx:43289 from yyy.yyy.yy.yy:5060 packet 1285608699.1202 DEBUG:<2> RESP 401 'Unauthorized' 1285608699.1228 DEBUG:<2> Net::SIP::Leg::deliver[330]: delivery from x +xx.xxx.xx.xx:43289 to udp:yyy.yyy.yy.yy:5060 OK: 1285608699.1228 DEBUG:<2> REQ REGISTER sip:yyy.yyy.yy.yy 1285608699.1247 DEBUG:<2> Net::SIP::Leg::receive[421]: received on xxx +.xxx.xx.xx:43289 from yyy.yyy.yy.yy:5060 packet 1285608699.1247 DEBUG:<2> RESP 100 'Trying' 1285608699.1281 DEBUG:<2> Net::SIP::Leg::receive[421]: received on xxx +.xxx.xx.xx:43289 from yyy.yyy.yy.yy:5060 packet 1285608699.1281 DEBUG:<2> REQ OPTIONS sip:user@xxx.xxx.xx.xx:43 +289 1285608699.1310 DEBUG:<2> Net::SIP::Leg::receive[421]: received on xxx +.xxx.xx.xx:43289 from yyy.yyy.yy.yy:5060 packet 1285608699.1310 DEBUG:<2> RESP 200 'OK' OK SEND INVITE... 1285608699.1355 DEBUG:<2> Net::SIP::Leg::deliver[330]: delivery from x +xx.xxx.xx.xx:43289 to udp:yyy.yyy.yy.yy:5060 OK: 1285608699.1355 DEBUG:<2> REQ INVITE sip:zzz.zzz.zz.zzz@yyy.yyy +.yy.yy with body 1285608699.1377 DEBUG:<2> Net::SIP::Leg::receive[421]: received on xxx +.xxx.xx.xx:43289 from yyy.yyy.yy.yy:5060 packet 1285608699.1377 DEBUG:<2> RESP 407 'Proxy Authentication Require +d' 1285608699.1397 DEBUG:<2> Net::SIP::Leg::deliver[330]: delivery from x +xx.xxx.xx.xx:43289 to yyy.yyy.yy.yy:5060 OK: 1285608699.1397 DEBUG:<2> REQ ACK sip:zzz.zzz.zz.zzz@yyy.yyy.yy +.yy 1285608699.1423 DEBUG:<2> Net::SIP::Leg::deliver[330]: delivery from x +xx.xxx.xx.xx:43289 to udp:yyy.yyy.yy.yy:5060 OK: 1285608699.1423 DEBUG:<2> REQ INVITE sip:zzz.zzz.zz.zzz@yyy.yyy +.yy.yy with body 1285608699.1446 DEBUG:<2> Net::SIP::Leg::receive[421]: received on xxx +.xxx.xx.xx:43289 from yyy.yyy.yy.yy:5060 packet 1285608699.1446 DEBUG:<2> RESP 488 'Not acceptable here' 1285608699.1466 DEBUG:<2> Net::SIP::Leg::deliver[330]: delivery from x +xx.xxx.xx.xx:43289 to yyy.yyy.yy.yy:5060 OK: 1285608699.1466 DEBUG:<2> REQ ACK sip:zzz.zzz.zz.zzz@yyy.yyy.yy +.yy OK 1285608700.1278 DEBUG:<2> Net::SIP::Leg::receive[421]: received on xxx +.xxx.xx.xx:43289 from yyy.yyy.yy.yy:5060 packet 1285608700.1278 DEBUG:<2> REQ OPTIONS sip:user@xxx.xxx.xx.xx:43 +289 1285608701.1286 DEBUG:<2> Net::SIP::Leg::receive[421]: received on xxx +.xxx.xx.xx:43289 from yyy.yyy.yy.yy:5060 packet 1285608701.1286 DEBUG:<2> REQ OPTIONS sip:user@xxx.xxx.xx.xx:43 +289 1285608702.1284 DEBUG:<2> Net::SIP::Leg::receive[421]: received on xxx +.xxx.xx.xx:43289 from yyy.yyy.yy.yy:5060 packet 1285608702.1284 DEBUG:<2> REQ OPTIONS sip:user@xxx.xxx.xx.xx:43 +289 1285608703.1282 DEBUG:<2> Net::SIP::Leg::receive[421]: received on xxx +.xxx.xx.xx:43289 from yyy.yyy.yy.yy:5060 packet 1285608703.1282 DEBUG:<2> REQ OPTIONS sip:user@xxx.xxx.xx.xx:43 +289


Can anyone help me with this?

Replies are listed 'Best First'.
Re: Getting error '488' using Net::SIP::Simple (RTFM)
by tye (Sage) on Sep 27, 2010 at 19:52 UTC

    The SIP RFC has these things to say about 488:

    21.4.26 488 Not Acceptable Here

    The response has the same meaning as 606 (Not Acceptable), but only applies to the specific resource addressed by the Request-URI and the request may succeed elsewhere.

    A message body containing a description of media capabilities MAY be present in the response, which is formatted according to the Accept header field in the INVITE (or application/sdp if not present), the same as a message body in a 200 (OK) response to an OPTIONS request.

    The first paragraph describing 606 says:

    21.6.4 606 Not Acceptable

    The user's agent was contacted successfully but some aspects of the session description such as the requested media, bandwidth, or addressing style were not acceptable.

    So you probably need to enable a different codec.

    Elsewhere, 488 is mentioned as follows:

    A UAS rejecting an offer contained in an INVITE SHOULD return a 488 (Not Acceptable Here) response. Such a response SHOULD include a Warning header field value explaining why the offer was rejected.

    So look at the 488 response packet and see what explanation is included in that header.

    Also, look at the message bodies to see what codecs are being offered by each side.

    - tye        

Re: Getting error '488' using Net::SIP::Simple
by gman (Friar) on Sep 27, 2010 at 19:53 UTC
    Hello,

    I believe , your invite needs to be formatted like a typical SIP URI;

    sip:<extension>@<ip_address>

    http://www.voip-info.org/wiki/view/SIP+URI
    1285616672.1717 DEBUG:<2> REQ INVITE sip:2145555555@192.168.1.2 +54 with body 1285616672.1753 DEBUG:<2> Net::SIP::Leg::receive[421]: received on 192 +.168.1.254:42508 from 192.168.1.254:5060 packet

    Your asterisk has to either have an extension built for the address / phone number in sip.conf and extensions.conf or your registered agent must have access to your outbound context in extensions.conf and match a extension;  exten => _1NXXNXXXXXX

    UPDATE: I tested your code and it works, correcting the URI. Also, the extension does not have to be _1NXX.... it just has to match your dialing pattern.

Re: Getting error '488' using Net::SIP::Simple
by Skaraluk (Initiate) on Sep 30, 2010 at 17:03 UTC
    I first have to thank you for answering my question, I've tried both of your ideas.

    tye, I've looked into the response and I can't find any warning header.

    gman, I've changed the URI using the extension of the phone, now is someting like this <extension>@<pbx_ip> but I still get the same error.
    Now the weird thing is, why the asterisk send me a '407 Proxy Authentication Required' if we don't have a proxy, could this be the problem? and how can I fix that?