Subject: | Timeout not reset between connects |
When connecting to a server a second time, it seems that the original
timeout window is used. Here's an example:
[root@epbxhou jabber]# cat astman.pl
#!/usr/bin/perl
use Asterisk::AMI;
use strict;
print time()." Connecting\n";
my $astman = Asterisk::AMI->new( 'PeerAddr' => '127.0.0.1',
'PeerPort' => 5038,
'Username' => 'jabber',
'Timeout' => 10,
'Secret' => 'somesecret' ) or
die('Unable to connect to Asterisk');
$astman->disconnect();
print time()." Sleeping\n";
sleep(20);
print time()." Connecting again\n";
$astman = Asterisk::AMI->new( 'PeerAddr' => '127.0.0.1',
'PeerPort' => 5038,
'Username' => 'jabber',
'Timeout' => 10,
'Secret' => 'somesecret' ) or
die('Unable to connect to Asterisk');
print "Dead\n";
[root@epbxhou jabber]#
[root@epbxhou jabber]#
[root@epbxhou jabber]#
[root@epbxhou jabber]# time perl astman.pl
1283899417 Connecting
1283899417 Sleeping
1283899437 Connecting again
Timed out waiting for login at
/usr/lib/perl5/site_perl/5.8.8/Asterisk/AMI.pm line 1248.
Unable to connect to Asterisk at astman.pl line 15.
real 0m20.090s
user 0m0.039s
sys 0m0.010s
[root@epbxhou jabber]#
The "Timed out waiting" appears immediately after the "Connecting again"
text shows up. If I increase the timeout to 60, it works fine:
[root@epbxhou jabber]# grep -i timeout astman.pl
'Timeout' => 60,
'Timeout' => 60,
[root@epbxhou jabber]# time perl astman.pl
1283899500 Connecting
1283899500 Sleeping
1283899520 Connecting again
Dead
real 0m20.131s
user 0m0.044s
sys 0m0.005s
[root@epbxhou jabber]#
Using Asterisk::AMI installed with CPAN, version 0.2.1. Perl 5.8.8 on
CentOS 5.3 (Linux 2.6.18 'sh)