Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
02-20-2013, 09:22 AM
|
#1
|
LQ Newbie
Registered: Feb 2013
Posts: 1
Rep: 
|
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
|
|
|
02-20-2013, 11:55 AM
|
#2
|
LQ Guru
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 27,609
|
Quote:
Originally Posted by Telleraine
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.
|
|
|
All times are GMT -5. The time now is 06:34 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|