Skip Menu |

This queue is for tickets about the Net-STOMP-Client CPAN distribution.

Report information
The Basics
Id: 57262
Status: resolved
Priority: 0/
Queue: Net-STOMP-Client

People
Owner: Nobody in particular
Requestors: pboyd [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.9
Fixed in: 0.9.1



Subject: High-level API methods can hang when server goes away
If the server Net::STOMP::Client is connected to goes away, subsequent attempts to send data will fail when using the high-level API methods. Initially when the server goes away, the process gets a SIGPIPE, so that must be trapped to see this behavior. The attached script demonstrates the problem. It just submits messages in a loop. If the server is stopped while that script is running it will hang. strace reports it's waiting on select: $ strace -p 15497 Process 15497 attached - interrupt to quit select(8, NULL, [3], NULL, NULL The problem appears to be that the high-level API methods don't provide a timeout value when they call send_frame, and neither send_frame frame nor Net::STOMP::Client::IO provide a default. I think this could be fixed by making send_frame use $self->timeout() if the timeout argument isn't set. And possibly initialize timeout() to some sane value. I can submit a patch for this, if it sounds reasonable.
Subject: stomp_producer.pl
#!/bin/env perl BEGIN {$^W = 1} use strict; use Net::STOMP::Client; my $stomp = Net::STOMP::Client->new( host => 'localhost', port => 61612 ); $stomp->connect(login => '', password => ''); my $done = 0; $SIG{INT} = sub { $done++ }; $SIG{PIPE} = 'IGNORE'; my $i = 0; while (!$done) { eval { $i++; print "Sending message #$i\n"; $stomp->send( destination => '/queue/test', body => $i, ); sleep 1; }; print "Error: $@\n" if ($@); } $stomp->disconnect();
From: pboyd [...] mcclatchyinteractive.com
On Thu May 06 11:44:06 2010, pboyd wrote: Show quoted text
> If the server Net::STOMP::Client is connected to goes away, subsequent > attempts to send data will fail when using the high-level API methods. >
That was supposed to say "will hang", not "will fail". Sorry.
From: pboyd [...] mcclatchyinteractive.com
I'm attaching a very small patch for this issue. Seems to work well enough for my purposes.
Subject: 0001-Set-timeout-in-send_frame.patch
From aadc8cb0679da926d18a39f36762605e4e940cb4 Mon Sep 17 00:00:00 2001 From: Paul Boyd <pboyd@pboyd-laptop.local> Date: Thu, 13 May 2010 11:26:29 -0400 Subject: [PATCH] Set timeout in send_frame. --- lib/Net/STOMP/Client.pm | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/lib/Net/STOMP/Client.pm b/lib/Net/STOMP/Client.pm index 6355db5..6e7a27d 100644 --- a/lib/Net/STOMP/Client.pm +++ b/lib/Net/STOMP/Client.pm @@ -241,6 +241,8 @@ sub send_frame : method { my($self, $frame, $timeout) = @_; my($done, $receipt); + $timeout = $self->timeout() unless defined $timeout; + # always check the sent frame $frame->check() or return(); # keep track of receipts -- 1.6.3.3
This has been fixed in version 0.9.1 (released today in CPAN). All STOMP methods can now take an optional timeout parameter. In addition, a global timeout for sending frames will be added for 0.9.2.