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();