LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 02-20-2013, 09:22 AM   #1
Telleraine
LQ Newbie
 
Registered: Feb 2013
Posts: 1

Rep: Reputation: Disabled
Linux to Linux Telnet on port 5038 failing


Greetings,

I have a bit of a puzzle going at my shop and after much useless searching via Google, decided to ask the true experts...

Setup:

PBX (Asterisk/PBX in a Flash)
MAX (CentOS)
Blast (Ubuntu)

We wrote a simple perl script that sends the extension and phone number to the PBX on port 5038 so that it tells the phone to dial the number. Testing it via Perl on my W7 machine worked flawlessly. Loaded it on to the MAX server, where it will actually be executing, and it fails. As a test, loaded it onto the Blast server and it worked. The MAX server has other perl scripts on it, that work fine, just for some reason this one does not. We have tried using a different port, disabling firewalls on both sides, manually executing the commands via telnet and nothing seems to work...

Here is the script:

Code:
#!/usr/bin/perl
#create a user agent object

####################################################################
# This perl script expects to be handed the extension of the phone 
# and the number to call.  It uses the Asters AMI interface and 
# assumes default user name and password.
#
# Syntax:
#
# pdial.pl 201 2159441092
####################################################################
# Parse out arguments - extension and number to dial
####################################################################
$numArgs = $#ARGV + 1;

if ($numArgs != 2) {
print "Error: There are arguments missing from the sys command";
die;
}

foreach $argnum (0 .. $#ARGV) {
   push (@stack, $ARGV[$argnum]);
}

####################################################################
# Save arguments to variables
####################################################################
$ext = @stack[0];
$phone = @stack[1];

####################################################################
# Establish connection to Asterisk dialer
####################################################################
use IO::Socket;
my $sock = new IO::Socket::INET (
                                 PeerAddr => '10.1.1.xxx', 
                                 PeerPort => '5038',
                                 Proto => 'tcp',
                                );
die "Could not create socket: $!\n" unless $sock; 

####################################################################
# Log onto Asterisk dialer interface - AMI Portal
####################################################################
print $sock "Action: Login\r\n"; 
print $sock "UserName: appuser\r\n";
print $sock "Secret: *****\r\n";

####################################################################
# Placing a call from an outgoing channel to a local extension, 
# this will cause the local extension not to ring 
# until the Zap channel has picked up
####################################################################
print $sock "Action: Originate\r\n"; 
print $sock "Channel: SIP/" . $ext . "\r\n";
print $sock "Context: from-internal\r\n"; 
print $sock "Exten: " . $phone . "\r\n"; 
print $sock "Priority: 1\r\n" ; 
print $sock "Timeout: 30000\r\n";
#print $sock "Account: " . $account . "\r\n";
print $sock "Async: yes\r\n" ;  

####################################################################
# Close socket and exit
####################################################################
close($sock);
We are at a loss to why it fails to run. We do not get the die script, since it successfully connects, it just seems like it is timing out midway through sending the commands. Which is also what happens if we manually connect and try to type in the commands. We get 3 or 4 in and the connection is closed by remote host.

Thanks.

Brian
 
Old 02-20-2013, 11:55 AM   #2
TB0ne
Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 15,996

Rep: Reputation: 2982Reputation: 2982Reputation: 2982Reputation: 2982Reputation: 2982Reputation: 2982Reputation: 2982Reputation: 2982Reputation: 2982Reputation: 2982Reputation: 2982
Quote:
Originally Posted by Telleraine View Post
Greetings,
I have a bit of a puzzle going at my shop and after much useless searching via Google, decided to ask the true experts...

Setup:
PBX (Asterisk/PBX in a Flash)
MAX (CentOS)
Blast (Ubuntu)

We wrote a simple perl script that sends the extension and phone number to the PBX on port 5038 so that it tells the phone to dial the number. Testing it via Perl on my W7 machine worked flawlessly. Loaded it on to the MAX server, where it will actually be executing, and it fails. As a test, loaded it onto the Blast server and it worked. The MAX server has other perl scripts on it, that work fine, just for some reason this one does not. We have tried using a different port, disabling firewalls on both sides, manually executing the commands via telnet and nothing seems to work...

We are at a loss to why it fails to run. We do not get the die script, since it successfully connects, it just seems like it is timing out midway through sending the commands. Which is also what happens if we manually connect and try to type in the commands. We get 3 or 4 in and the connection is closed by remote host.
Since it runs on Ubuntu and (I'm assuming) you don't get perl compilation errors on the CentOS machine, that is a puzzle. You could try to put print statements after each set of commands, to see how far it's getting, to give you some indication of where it's dying. Can you manually telnet to the address/port from the CentOS system command-line? You say you tried to manually run the commands, so I'm assuming that doesn't work via just "telnet" from a terminal, interactively. If you can't telnet to the port manually, then you have some sort of network issue between the CentOS box and the PBX server, whether it be firewall, iptables, or selinux. You say you disabled the firewalls...what kind were they, and are you just talking about iptables rules? Is there some sort of ACL in place on the PBX, to let in certain addresses?

Also, the error line can be re-written as:
Code:
if ($numArgs != 2) {
   die "Error: \t There are arguments missing from the command-line\n\nUsage: \n\t pdial.pl \<Phone Extension\> \<Number to call\>\n";
}
..which will give the user some idea what to put in, and in what order, if things croak, and will leave out the print line. Just my $0.02, and worth half-that at least.

Last edited by TB0ne; 02-20-2013 at 11:59 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
telnet slowness - linux telnet vs windows telnet vahab Linux - Networking 4 01-23-2013 02:25 PM
PLESK [Solution] Change port to 23 (telnet) instead of default port 8443 x5452 Linux - Software 6 05-10-2009 05:58 AM
Unable to telnet to Linux Host inspite of installing telnet-server RPM - Need Help sinamdar Linux - Software 7 04-11-2009 07:09 AM
Piping to telnet 80 failing michaelsanford Linux - Networking 2 01-19-2006 04:20 PM
Failing to connect to TELNET, FTP or SSH dbadft Linux - Networking 10 04-16-2003 02:44 PM


All times are GMT -5. The time now is 04:27 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration