omniti-labs / Net--RabbitMQ

Perl bindings to the librabbitmq-c AMQP library.
Other
25 stars 18 forks source link

Simple receiver fails with "recv() failed: Bad frame read." #32

Closed doconeill closed 11 years ago

doconeill commented 11 years ago

I'm starting a new project using RabbitMQ, and I've used Net::RabbitMQ in the past, but now with the latest versions I'm running into a show-stopper.

Even with a simple receiver, I get a "recv() failed: Bad frame read." (similar to issues #12 and #20 ), except I'm not setting a heatbeat at all. It happens after waiting for a message for 30 seconds.

After playing with setting heartbeats, it seems to always fail at 3 times the heartbeat - i.e. if I set it to 5 seconds, it fails at 15 seconds, or if I set it to 60 seconds it fails at 180. If not set (or set to 0), it fails at 30. Setting it negative results in a error on connection.

This is with 0.2.6 with rabbitmq-c 0.3.0, against server 3.0.4. I tried older versions (0.2.2/0.0.1) which I've used successfully in the past, and they do the same thing :(

Seriously simple code below:

!/usr/bin/perl

use Net::RabbitMQ;

use Data::Dumper;

$mqserver = 'localhost'; $mquser = 'guest'; $mqpass = 'guest'; $mqvhost = '/'; $mqport = 5672; $mqtimeout = 30;

$queue = 'testexec'; $exchange = 'test';

print "Setting up connection\n"; my $mq = Net::RabbitMQ->new(); $mq->connect($mqserver, { user => $mquser, password => $mqpass, port => $mqport, vhost => $mqvhost, timeout => $mqtimeout,

heartbeat => 1,

});

print "Opening channel\n"; $mq->channel_open(1);

eval { $mq->exchange_declare(1, $exchange, { exchange_type => 'direct', auto_delete => 0, durable => 1, }); }; if ($@) { print "exchange_declare() failed: $@\n"; exit 3; }

eval { $mq->consume(1,$queue,{ no_ack => 0 }); }; if ($@) { print "consume() failed: $@\n"; exit 3; } eval { $msg = $mq->recv(); }; if ($@) { print "recv() failed: $@\n"; exit 3; }

print Dumper $msg;

doconeill commented 11 years ago

Bah...after the cut-and-paste, I noted I set the timeout value - which seems to likewise cause this problem. If heartbeat is set, it is 3xHeartbeat. Otherwise it's timeout. I though the timeout was for the initial connection...

mjegh commented 9 years ago

I know this issue is really old but in the hope you can remember. I am experiencing the same problem setting heartbeat to anything other than 0. What did you do in the end?