Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server disconnection are not detected #24

Open
romainneutron opened this issue Apr 5, 2013 · 5 comments
Open

Server disconnection are not detected #24

romainneutron opened this issue Apr 5, 2013 · 5 comments

Comments

@romainneutron
Copy link
Contributor

For example, run php examples/publish.php rabbitmq, shutdown Rabbit MQ server, see that it continues to send frames, no exception thrown

@romainneutron
Copy link
Contributor Author

There is currently no way to prevent this. Heartbeat or receipt could improve this

@romainneutron
Copy link
Contributor Author

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 ?

@igorw
Copy link
Contributor

igorw commented Apr 5, 2013

This issue is new to me. But @cboden mentioned a similar issue related to libev and libuv loops. Which loop are you using?

@romainneutron
Copy link
Contributor Author

I'm using libevent

@romainneutron
Copy link
Contributor Author

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

blex18 added a commit to blex18/stomp that referenced this issue Feb 11, 2015
teefax pushed a commit to teefax/stomp that referenced this issue Nov 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants