|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2010-05-15 21:27 UTC] alex at zander dot net
Description:
------------
I am attempting to connect to a RabbitMQ service that has
been tested and is known to support connections via STOMP
using other methods.
I have installed this PECL and it appears to be installed
correctly because it is included in the output from
phpinfo() and the RabbitMQ log file shows my PHP application
connecting successfully.
My PHP application is run from the command-line (i.e. not
via a web server) and it executes successfully but when it
reaches the line that instantiates the Stomp class it
freezes and does not progress or terminate until I kill it
using CTRL-C.
Reproduce code:
---------------
#!/usr/bin/php
<?
try {
$URI = 'tcp://localhost:61613';
$conn = new Stomp ( 'tcp://localhost:61613', 'guest', 'guest' );
} catch( StompException $e ) {
die( $e->getMessage()."\n" );
}
echo "This line never gets executed!";
?>
Expected result:
----------------
When running the application from the command-line, it should
execute and output the string "This line never gets
executed!".
Actual result:
--------------
If the username or password are incorrect or not included then
the application outputs "Unexpected EOF while reading from
socket" and terminates.
If the username and password are correct then the application
does not do anything - it does not return from the Stomp
class's constructor and nothing is output. The application
does not terminate until I manually terminate it using CTRL-C.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 13:00:01 2025 UTC |
It would seem, the current implementation of the fix is still buggy. In this code: if (stomp_select_ex(stomp, 0, 0)) { char endline[1]; if (1 != stomp_recv(stomp, endline, 1) && '\n' != endline[0]) { if (*data) { efree(*data); *data = NULL; } return 0; } } it is possible for stomp_recv to return 0 or -1 -- and not place anything in endline. The memory in the "array" will then be uninitialized, which will SOMETIMES cause the read-failure (when the byte happens to match \n). Something like this is needed: char endline = '\0'; if (1 != stomp_recv(stomp, &endline, 1) && '\n' != endline) { also, even though false is returned, there is no error set to explain why -- something I fix carefully in the patch attached to Bug 64670.Likewise, this code: length = stomp_recv(stomp, endbuffer, 2); if (endbuffer[0] != '\0' || ((2 == length) && (endbuffer[1] != '\n'))) { RETURN_READ_FRAME_FAIL; would fail, if the length returned is less than 1.