Open romainneutron opened 11 years ago
There is currently no way to prevent this. Heartbeat or receipt could improve this
It appears that React\Stream\Buffer
does not catch an error on fwrite
call.
I added an exit (that is never reached when I shutdown RabbitMQ) in React\Stream\Buffer
at line 94 like this :
if (false === $sent) {
exit('tadaaa');
$this->emit('error', array(new \ErrorException(
$this->lastError['message'],
0,
$this->lastError['number'],
$this->lastError['file'],
$this->lastError['line']
)));
return;
}
Is it a know issue @igorw ?
This issue is new to me. But @cboden mentioned a similar issue related to libev and libuv loops. Which loop are you using?
I'm using libevent
The error can be reproduced with a simple script :
$fd = stream_socket_client('tcp://localhost:61613', $errno, $errstr);
stream_set_blocking($fd, 0);
$initialized = false;
fwrite($fd, "CONNECT\naccept-version:1.1\nhost:/\nlogin:guest\npasscode:guest\n\n\x00");
while (true) {
$read = fread($fd, 1024);
if ($read) {
echo "Read : $read\n";
if (0 === strpos($read, "CONNECTED\n")) {
$initialized = true;
echo "Initialized !\n";
}
}
if ($initialized) {
echo "Sending frame...\n";
fwrite($fd, "SEND\ndestination:/topic/foo\ncontent-length:10\ncontent-type:text/plain\n\nle message\x00");
usleep(500000);
}
}
when running this script and shutdown RabbitMQ produces :
➜ react-stomp git:(master) ✗ php test-stream.php
Read : CONNECTED
session:session-gzyp_Sp1VOjbI9u9wDK5yw
heart-beat:0,0
server:RabbitMQ/3.0.4
version:1.1
Initialized !
Sending frame...
Sending frame...
Sending frame...
Sending frame...
PHP Notice: fwrite(): send of 82 bytes failed with errno=32 Broken pipe in /Users/romain/Documents/workspace/react-stomp/test-stream.php on line 24
PHP Stack trace:
PHP 1. {main}() /Users/romain/Documents/workspace/react-stomp/test-stream.php:0
PHP 2. fwrite() /Users/romain/Documents/workspace/react-stomp/test-stream.php:24
For example, run
php examples/publish.php rabbitmq
, shutdown Rabbit MQ server, see that it continues to send frames, no exception thrown