Skip Menu |

This queue is for tickets about the Asterisk-AMI CPAN distribution.

Report information
The Basics
Id: 61148
Status: resolved
Priority: 0/
Queue: Asterisk-AMI

People
Owner: GREENBEAN [...] cpan.org
Requestors: sup2000 [...] hotmail.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: v0.2.0
Fixed in: v0.2.2



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)
Thanks for the report. I verified this under perl 5.10.1 on debian as well. The problem appears to be that the call to sleep is causing the internal eventloop that is called to wait for responses to become out of date (it thinks it is 20 seconds in the past) when we install our timers for detecting a timeout. Once the eventloop does update it has now jumped forward the number of seconds you slept and you get an instant timeout. The fix is to force an update to the event loop, before installing timeouts, when doing blocking calls. I have fixed your particular example but just need to make sure I am updating the eventloop at all the appropriate areas. I hope to put up a fixed release tomorrow.
The updated version on GitHub should fix this issue for you. Could you please download the new version from their and verify? http://github.com/rrb3942/perl-Asterisk-AMI Direct Link to tar: http://github.com/rrb3942/perl-Asterisk-AMI/tarball/master Once you verify I will push the update to CPAN. Thanks.
From: sup2000 [...] hotmail.com
Just tested this out and it works without issue! I used sleep for my example, the actual problematic code was doing some other sort of sleep-like behavior. This did the trick. Thank you! On Tue Sep 07 21:20:35 2010, GREENBEAN wrote: Show quoted text
> The updated version on GitHub should fix this issue for you. Could you > please download the new version from their and verify? > > http://github.com/rrb3942/perl-Asterisk-AMI > > Direct Link to tar: > http://github.com/rrb3942/perl-Asterisk-AMI/tarball/master > > Once you verify I will push the update to CPAN. > > Thanks.
Thanks for your help, the updated version is now available on CPAN.