I wanted to build an awesome place for people to discuss module specific issues, but I don't have any more time for this, and there are much better places to discuss Perl-related issues. I'd recommend asking your question on Stack Overflow or on Perl Monks.
If you are looking for a Perl tutorial or Perl-related news, I hope these links will serve you well.
Posted on 2010-10-08 10:22:53.107789-07 by skaraluk
Why I get a 407 Request?
Hi everyone, I had posted here before asking about a Softphone I'm programming, after then I've advanced a lot but I'm stuck again, so I'm here to ask again hehe.
This is my code:
#!/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*=6Registrar=1 ); Net::SIP::Debug->level(6); $| = 1; my $ip_me = '192.168.11.73'; #server executing the code my $ip_pbx = '192.168.11.99'; #asterisk my $ip_to = '24'; #the annex number of the ip phone 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-8000' ); print 'OK'.$/; # create new agent print 'CREATING AGENT... '; my $ua = Net::SIP::Simple->new( registrar => $ip_me, domain => $ip_pbx.':5060', from => 'user', leg => $leg_tel_1, auth => ['user','password'] #user and password provided in the asterisk 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 => $ua->rtp( 'send_recv', 'announcement.pcmu-8000' )); #$ua->invite( $ip_to, init_media => $echo_10, asymetric_rtp => 1); $err = $ua->error; if ($err ne ''){ print $err.$/; } print 'OK'.$/; $ua->loop;


And this is what I get:
CREATING SOCKET AND LEG... OK CREATING RTP... OK CREATING AGENT... OK TRY TO REGISTER... 1286556354.2467 DEBUG:<2> Net::SIP::Leg::deliver[330]: delivery from 192.168.11.73:56689 to udp:192 +.168.11.73:5060 OK: 1286556354.2467 DEBUG:<2> REGISTER sip:192.168.11.73 SIP/2.0 1286556354.2467 DEBUG:<2> Via: SIP/2.0/UDP 192.168.11.73:56689;branch=z9hG4bK1db37b33d734499d +41dfb83e36ff9f8ec0e2f4ccae58c77af3028ada67b1158f 1286556354.2467 DEBUG:<2> Call-id: 4d254f8eb17da1a248c89e6f14b1bf26 1286556354.2467 DEBUG:<2> Contact: user <sip:user@192.168.11.73:56689> 1286556354.2467 DEBUG:<2> Cseq: 1 REGISTER 1286556354.2467 DEBUG:<2> Expires: 900 1286556354.2467 DEBUG:<2> From: user <sip:user@192.168.11.99:5060>;tag=78e0a4e7d9c260f8cdaf5e +ef74cd5006 1286556354.2467 DEBUG:<2> Max-forwards: 70 1286556354.2467 DEBUG:<2> To: user <sip:user@192.168.11.99:5060> 1286556354.2467 DEBUG:<2> Content-length: 0 1286556354.2467 DEBUG:<2> 1286556354.2467 DEBUG:<2> 1286556354.2628 DEBUG:<2> Net::SIP::Leg::receive[421]: received on 192.168.11.73:56689 from 192.168 +.11.99:5060 packet 1286556354.2628 DEBUG:<2> SIP/2.0 100 Trying 1286556354.2628 DEBUG:<2> Via: SIP/2.0/UDP 192.168.11.73:56689;branch=z9hG4bK1db37b33d734499d +41dfb83e36ff9f8ec0e2f4ccae58c77af3028ada67b1158f;received=192.168.11.73 1286556354.2628 DEBUG:<2> From: user <sip:user@192.168.11.99:5060>;tag=78e0a4e7d9c260f8cdaf5e +ef74cd5006 1286556354.2628 DEBUG:<2> To: user <sip:user@192.168.11.99:5060> 1286556354.2628 DEBUG:<2> Call-ID: 4d254f8eb17da1a248c89e6f14b1bf26 1286556354.2628 DEBUG:<2> CSeq: 1 REGISTER 1286556354.2628 DEBUG:<2> User-Agent: Asterisk PBX 1286556354.2628 DEBUG:<2> Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY 1286556354.2628 DEBUG:<2> Contact: <sip:user@192.168.11.99> 1286556354.2628 DEBUG:<2> Content-Length: 0 1286556354.2628 DEBUG:<2> 1286556354.2628 DEBUG:<2> 1286556354.2681 DEBUG:<2> Net::SIP::Leg::receive[421]: received on 192.168.11.73:56689 from 192.168 +.11.99:5060 packet 1286556354.2681 DEBUG:<2> SIP/2.0 401 Unauthorized 1286556354.2681 DEBUG:<2> Via: SIP/2.0/UDP 192.168.11.73:56689;branch=z9hG4bK1db37b33d734499d +41dfb83e36ff9f8ec0e2f4ccae58c77af3028ada67b1158f;received=192.168.11.73 1286556354.2681 DEBUG:<2> From: user <sip:user@192.168.11.99:5060>;tag=78e0a4e7d9c260f8cdaf5e +ef74cd5006 1286556354.2681 DEBUG:<2> To: user <sip:user@192.168.11.99:5060>;tag=as0b600264 1286556354.2681 DEBUG:<2> Call-ID: 4d254f8eb17da1a248c89e6f14b1bf26 1286556354.2681 DEBUG:<2> CSeq: 1 REGISTER 1286556354.2681 DEBUG:<2> User-Agent: Asterisk PBX 1286556354.2681 DEBUG:<2> Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY 1286556354.2681 DEBUG:<2> Contact: <sip:user@192.168.11.99> 1286556354.2681 DEBUG:<2> WWW-Authenticate: Digest realm="asterisk", nonce="78a09c5f" 1286556354.2681 DEBUG:<2> Content-Length: 0 1286556354.2681 DEBUG:<2> 1286556354.2681 DEBUG:<2> 1286556354.2723 DEBUG:<2> Net::SIP::Leg::deliver[330]: delivery from 192.168.11.73:56689 to udp:192 +.168.11.73:5060 OK: 1286556354.2723 DEBUG:<2> REGISTER sip:192.168.11.73 SIP/2.0 1286556354.2723 DEBUG:<2> Via: SIP/2.0/UDP 192.168.11.73:56689;branch=z9hG4bK1db37b33d734499d +41dfb83e36ff9f8e992392a7cd43d5e8363d22214413c4bd 1286556354.2723 DEBUG:<2> Call-id: 4d254f8eb17da1a248c89e6f14b1bf26 1286556354.2723 DEBUG:<2> Contact: user <sip:user@192.168.11.73:56689> 1286556354.2723 DEBUG:<2> Expires: 900 1286556354.2723 DEBUG:<2> From: user <sip:user@192.168.11.99:5060>;tag=78e0a4e7d9c260f8cdaf5e +ef74cd5006 1286556354.2723 DEBUG:<2> Max-forwards: 70 1286556354.2723 DEBUG:<2> To: user <sip:user@192.168.11.99:5060> 1286556354.2723 DEBUG:<2> Authorization: Digest username="user",realm="asterisk",nonce="78a09 +c5f",uri="sip:192.168.11.73",response="c528c84a041f983ca42be008e649f85b" 1286556354.2723 DEBUG:<2> Cseq: 2 REGISTER 1286556354.2723 DEBUG:<2> Content-length: 0 1286556354.2723 DEBUG:<2> 1286556354.2723 DEBUG:<2> 1286556354.2755 DEBUG:<2> Net::SIP::Leg::receive[421]: received on 192.168.11.73:56689 from 192.168 +.11.99:5060 packet 1286556354.2755 DEBUG:<2> SIP/2.0 100 Trying 1286556354.2755 DEBUG:<2> Via: SIP/2.0/UDP 192.168.11.73:56689;branch=z9hG4bK1db37b33d734499d +41dfb83e36ff9f8e992392a7cd43d5e8363d22214413c4bd;received=192.168.11.73 1286556354.2755 DEBUG:<2> From: user <sip:user@192.168.11.99:5060>;tag=78e0a4e7d9c260f8cdaf5e +ef74cd5006 1286556354.2755 DEBUG:<2> To: user <sip:user@192.168.11.99:5060> 1286556354.2755 DEBUG:<2> Call-ID: 4d254f8eb17da1a248c89e6f14b1bf26 1286556354.2755 DEBUG:<2> CSeq: 2 REGISTER 1286556354.2755 DEBUG:<2> User-Agent: Asterisk PBX 1286556354.2755 DEBUG:<2> Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY 1286556354.2755 DEBUG:<2> Contact: <sip:user@192.168.11.99> 1286556354.2755 DEBUG:<2> Content-Length: 0 1286556354.2755 DEBUG:<2> 1286556354.2755 DEBUG:<2> 1286556354.2795 DEBUG:<2> Net::SIP::Leg::receive[421]: received on 192.168.11.73:56689 from 192.168 +.11.99:5060 packet 1286556354.2795 DEBUG:<2> OPTIONS sip:user@192.168.11.73:56689 SIP/2.0 1286556354.2795 DEBUG:<2> Via: SIP/2.0/UDP 192.168.11.99:5060;branch=z9hG4bK07c533cd;rport 1286556354.2795 DEBUG:<2> From: "asterisk" <sip:asterisk@192.168.11.99>;tag=as30bf73ee 1286556354.2795 DEBUG:<2> To: <sip:user@192.168.11.73:56689> 1286556354.2795 DEBUG:<2> Contact: <sip:asterisk@192.168.11.99> 1286556354.2795 DEBUG:<2> Call-ID: 7f1b39264c77350c5e2047980956cb83@192.168.11.99 1286556354.2795 DEBUG:<2> CSeq: 102 OPTIONS 1286556354.2795 DEBUG:<2> User-Agent: Asterisk PBX 1286556354.2795 DEBUG:<2> Max-Forwards: 70 1286556354.2795 DEBUG:<2> Date: Fri, 08 Oct 2010 16:41:27 GMT 1286556354.2795 DEBUG:<2> Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY 1286556354.2795 DEBUG:<2> Content-Length: 0 1286556354.2795 DEBUG:<2> 1286556354.2795 DEBUG:<2> 1286556354.2839 DEBUG:<2> Net::SIP::Leg::receive[421]: received on 192.168.11.73:56689 from 192.168 +.11.99:5060 packet 1286556354.2839 DEBUG:<2> SIP/2.0 200 OK 1286556354.2839 DEBUG:<2> Via: SIP/2.0/UDP 192.168.11.73:56689;branch=z9hG4bK1db37b33d734499d +41dfb83e36ff9f8e992392a7cd43d5e8363d22214413c4bd;received=192.168.11.73 1286556354.2839 DEBUG:<2> From: user <sip:user@192.168.11.99:5060>;tag=78e0a4e7d9c260f8cdaf5e +ef74cd5006 1286556354.2839 DEBUG:<2> To: user <sip:user@192.168.11.99:5060>;tag=as0b600264 1286556354.2839 DEBUG:<2> Call-ID: 4d254f8eb17da1a248c89e6f14b1bf26 1286556354.2839 DEBUG:<2> CSeq: 2 REGISTER 1286556354.2839 DEBUG:<2> User-Agent: Asterisk PBX 1286556354.2839 DEBUG:<2> Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY 1286556354.2839 DEBUG:<2> Expires: 900 1286556354.2839 DEBUG:<2> Contact: <sip:user@192.168.11.73:56689>;expires=900 1286556354.2839 DEBUG:<2> Date: Fri, 08 Oct 2010 16:41:27 GMT 1286556354.2839 DEBUG:<2> Content-Length: 0 1286556354.2839 DEBUG:<2> 1286556354.2839 DEBUG:<2> OK SEND INVITE... 1286556354.2894 DEBUG:<2> Net::SIP::Leg::deliver[330]: delivery from 192.168.11.73:56689 to udp:192 +.168.11.99:5060 OK: 1286556354.2894 DEBUG:<2> INVITE sip:+24@192.168.11.99:5060 SIP/2.0 1286556354.2894 DEBUG:<2> Supported: 1286556354.2894 DEBUG:<2> Allow: INVITE, ACK, OPTIONS, CANCEL, BYE 1286556354.2894 DEBUG:<2> Contact: sip:user@192.168.11.73:56689 1286556354.2894 DEBUG:<2> Via: SIP/2.0/UDP 192.168.11.73:56689;branch=z9hG4bK1db37b33d734499d +41dfb83e36ff9f8e9c71010c0f42810937418f5aee95f8d0 1286556354.2894 DEBUG:<2> Call-id: 45804fce3d81dbb804cb1c68a4b27e5f 1286556354.2894 DEBUG:<2> Cseq: 1 INVITE 1286556354.2894 DEBUG:<2> From: user <sip:user@192.168.11.99:5060>;tag=c03638557ccd8e98caabc6 +7cf535bbe4 1286556354.2894 DEBUG:<2> Max-forwards: 70 1286556354.2894 DEBUG:<2> To: +24 <sip:+24@192.168.11.99:5060> 1286556354.2894 DEBUG:<2> Content-type: application/sdp 1286556354.2894 DEBUG:<2> Content-length: 127 1286556354.2894 DEBUG:<2> 1286556354.2894 DEBUG:<2> v=0 1286556354.2894 DEBUG:<2> o=anonymous 1286556354 1286556354 IN IP4 192.168.11.73 1286556354.2894 DEBUG:<2> s=session 1286556354.2894 DEBUG:<2> c=IN IP4 192.168.11.73 1286556354.2894 DEBUG:<2> t=0 0 1286556354.2894 DEBUG:<2> m=audio 8476 RTP/AVP 0 1286556354.2894 DEBUG:<2> 1286556354.2917 DEBUG:<2> Net::SIP::Leg::receive[421]: received on 192.168.11.73:56689 from 192.168 +.11.99:5060 packet 1286556354.2917 DEBUG:<2> SIP/2.0 407 Proxy Authentication Required 1286556354.2917 DEBUG:<2> Via: SIP/2.0/UDP 192.168.11.73:56689;branch=z9hG4bK1db37b33d734499d +41dfb83e36ff9f8e9c71010c0f42810937418f5aee95f8d0;received=192.168.11.73 1286556354.2917 DEBUG:<2> From: user <sip:user@192.168.11.99:5060>;tag=c03638557ccd8e98caabc6 +7cf535bbe4 1286556354.2917 DEBUG:<2> To: +24 <sip:+24@192.168.11.99:5060>;tag=as143ca9b2 1286556354.2917 DEBUG:<2> Call-ID: 45804fce3d81dbb804cb1c68a4b27e5f 1286556354.2917 DEBUG:<2> CSeq: 1 INVITE 1286556354.2917 DEBUG:<2> User-Agent: Asterisk PBX 1286556354.2917 DEBUG:<2> Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY 1286556354.2917 DEBUG:<2> Contact: <sip:+24@192.168.11.99> 1286556354.2917 DEBUG:<2> Proxy-Authenticate: Digest realm="asterisk", nonce="7d287028" 1286556354.2917 DEBUG:<2> Content-Length: 0 1286556354.2917 DEBUG:<2> 1286556354.2917 DEBUG:<2> 1286556354.2936 DEBUG:<2> Net::SIP::Leg::deliver[330]: delivery from 192.168.11.73:56689 to 192.168 +.11.99:5060 OK: 1286556354.2936 DEBUG:<2> ACK sip:+24@192.168.11.99:5060 SIP/2.0 1286556354.2936 DEBUG:<2> Via: SIP/2.0/UDP 192.168.11.73:56689;branch=z9hG4bK1db37b33d734499d +41dfb83e36ff9f8e9c71010c0f42810937418f5aee95f8d0 1286556354.2936 DEBUG:<2> Call-id: 45804fce3d81dbb804cb1c68a4b27e5f 1286556354.2936 DEBUG:<2> Cseq: 1 ACK 1286556354.2936 DEBUG:<2> From: user <sip:user@192.168.11.99:5060>;tag=c03638557ccd8e98caabc6 +7cf535bbe4 1286556354.2936 DEBUG:<2> To: +24 <sip:+24@192.168.11.99:5060>;tag=as143ca9b2 1286556354.2936 DEBUG:<2> Content-length: 0 1286556354.2936 DEBUG:<2> 1286556354.2936 DEBUG:<2> 1286556354.2961 DEBUG:<2> Net::SIP::Leg::deliver[330]: delivery from 192.168.11.73:56689 to udp:192 +.168.11.99:5060 OK: 1286556354.2961 DEBUG:<2> INVITE sip:+24@192.168.11.99:5060 SIP/2.0 1286556354.2961 DEBUG:<2> Supported: 1286556354.2961 DEBUG:<2> Allow: INVITE, ACK, OPTIONS, CANCEL, BYE 1286556354.2961 DEBUG:<2> Contact: sip:user@192.168.11.73:56689 1286556354.2961 DEBUG:<2> Via: SIP/2.0/UDP 192.168.11.73:56689;branch=z9hG4bK1db37b33d734499d +41dfb83e36ff9f8e4735253722c2395012193374c756b945 1286556354.2961 DEBUG:<2> Call-id: 45804fce3d81dbb804cb1c68a4b27e5f 1286556354.2961 DEBUG:<2> From: user <sip:user@192.168.11.99:5060>;tag=c03638557ccd8e98caabc6 +7cf535bbe4 1286556354.2961 DEBUG:<2> Max-forwards: 70 1286556354.2961 DEBUG:<2> To: +24 <sip:+24@192.168.11.99:5060> 1286556354.2961 DEBUG:<2> Content-type: application/sdp 1286556354.2961 DEBUG:<2> Proxy-authorization: Digest username="user",realm="asterisk",nonce= +"7d287028",uri="sip:+24@192.168.11.99:5060",response="8712faaf864ba49ebd00b4e3f18aee35" 1286556354.2961 DEBUG:<2> Cseq: 2 INVITE 1286556354.2961 DEBUG:<2> Content-length: 127 1286556354.2961 DEBUG:<2> 1286556354.2961 DEBUG:<2> v=0 1286556354.2961 DEBUG:<2> o=anonymous 1286556354 1286556354 IN IP4 192.168.11.73 1286556354.2961 DEBUG:<2> s=session 1286556354.2961 DEBUG:<2> c=IN IP4 192.168.11.73 1286556354.2961 DEBUG:<2> t=0 0 1286556354.2961 DEBUG:<2> m=audio 8476 RTP/AVP 0 1286556354.2961 DEBUG:<2> 1286556354.2982 DEBUG:<2> Net::SIP::Leg::receive[421]: received on 192.168.11.73:56689 from 192.168 +.11.99:5060 packet 1286556354.2982 DEBUG:<2> SIP/2.0 488 Not acceptable here 1286556354.2982 DEBUG:<2> Via: SIP/2.0/UDP 192.168.11.73:56689;branch=z9hG4bK1db37b33d734499d +41dfb83e36ff9f8e4735253722c2395012193374c756b945;received=192.168.11.73 1286556354.2982 DEBUG:<2> From: user <sip:user@192.168.11.99:5060>;tag=c03638557ccd8e98caabc6 +7cf535bbe4 1286556354.2982 DEBUG:<2> To: +24 <sip:+24@192.168.11.99:5060>;tag=as143ca9b2 1286556354.2982 DEBUG:<2> Call-ID: 45804fce3d81dbb804cb1c68a4b27e5f 1286556354.2982 DEBUG:<2> CSeq: 2 INVITE 1286556354.2982 DEBUG:<2> User-Agent: Asterisk PBX 1286556354.2982 DEBUG:<2> Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY 1286556354.2982 DEBUG:<2> Contact: <sip:+24@192.168.11.99> 1286556354.2982 DEBUG:<2> Content-Length: 0 1286556354.2982 DEBUG:<2> 1286556354.2982 DEBUG:<2> 1286556354.3000 DEBUG:<2> Net::SIP::Leg::deliver[330]: delivery from 192.168.11.73:56689 to 192.168 +.11.99:5060 OK: 1286556354.3000 DEBUG:<2> ACK sip:+24@192.168.11.99:5060 SIP/2.0 1286556354.3000 DEBUG:<2> Via: SIP/2.0/UDP 192.168.11.73:56689;branch=z9hG4bK1db37b33d734499d +41dfb83e36ff9f8e4735253722c2395012193374c756b945 1286556354.3000 DEBUG:<2> Call-id: 45804fce3d81dbb804cb1c68a4b27e5f 1286556354.3000 DEBUG:<2> Cseq: 2 ACK 1286556354.3000 DEBUG:<2> From: user <sip:user@192.168.11.99:5060>;tag=c03638557ccd8e98caabc6 +7cf535bbe4 1286556354.3000 DEBUG:<2> To: +24 <sip:+24@192.168.11.99:5060>;tag=as143ca9b2 1286556354.3000 DEBUG:<2> Content-length: 0


As you can see I'm being rejected with a '488 Not acceptable here' Response, this is after the Asterisk server sent me a '407 Proxy Authentication Required' Request and the program tried to authenticate with my user and password. But the thing is... we don't have a proxy, so why I'm getting the 407 Request?. I used the same user and password in Zoiper and it works, so I know is something in the code, but I don't know what.
Please help me with this.
Direct Responses: 12989 | Write a response