Skip Menu |

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

Report information
The Basics
Id: 69636
Status: rejected
Priority: 0/
Queue: Net-STOMP-Client

People
Owner: Nobody in particular
Requestors: TJC [...] cpan.org
toby.corkindale [...] strategicdata.com.au
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 1.1
Fixed in: (no value)



Subject: MESSAGEs do not decode if server heart-beats have been received
Hi, I've come across an odd bug in Net::STOMP::Client. It occurs on version 1.1, once client and server heart-beats have been enabled, and more than one has already been received from the server. At this point, any subsequent MESSAGE frame will fail to be decoded. Looking at Net/STOMP/Client/Frame.pm, at approximately line 250, we have code like this: $temp = substr($$bufref, $state->{command_idx}, $state->{command_len}); unless ($temp =~ /^\s*($CommandRE)$/o) { Net::STOMP::Client::Error::report("%s: invalid command", $me); } Now this regex is failing because $temp contains leading nulls. I'm dumping out the value of $temp just prior, and I get the following results: $VAR1 = [ '', '', '', '', 'M', 'E', 'S', 'S', 'A', 'G', 'E' ]; again, with hexadecimal: $VAR1 = [ '00', '00', '00', '00', '4d', '45', '53', '53', '41', '47', '45' ]; I note that the number of leading nulls is equivalent to the number of server pings that have passed prior to the MESSAGE frame arriving. I have a bit of a workaround for this issue, which is to change the relevant code like so: unless ($temp =~ /^\x00*($CommandRE)$/o) { Net::STOMP::Client::Error::report("%s: invalid command", $me); } $frame->command($1); However my guess at the root cause here is that the index into the bufref is not coping with the code around line 241 that does $$bufref =~ s/\n+//; Cheers, Toby
Also, just a minor comment, but that error message could be more helpful if it reported what the invalid command was, rather than just the current function name. Eg: Net::STOMP::Client::Error::report("%s: invalid command: %s", $me, $temp, );
I should have added to this bug report: Tested on RabbitMQ 2.5.1 with their STOMP plugin of the same version, on both Debian 6.0 and Ubuntu 11.04.
Toby, The problem seems to come from a bug in RabbitMQ that seems to send NULLs instead of newlines. See http://groups.google.com/group/rabbitmq- discuss/msg/12bed6b6c20a4a6b. Let's see what the RabbitMQ people do with this... Regarding the cryptic error message, this has already been fixed in the trunk. Thanks for the suggestion.
I saw your message on the RabbitMQ list.. I agree, it does look like a bug at their end. For people stuck with the as-packaged-by-their-linux-distro versions of RabbitMQ, it might be nice to include some kind of compatibility flag to cope with the nulls too, so that people can use heart-beats there too.
This is indeed a bug on the RabbitMQ side and it has already been fixed: http://hg.rabbitmq.com/rabbitmq-stomp/rev/c787e1815eca. I'm sorry but I won't add workarounds in my code for bugs that have already been fixed. If you are stuck with a broken RabbitMQ, I suggest that you patch my code. Just replace the corresponding \n by [\n\0] where it's relevant in Frame.pm (three places).