{"action":"created","issue":{"url":"https://api.github.com/repos/php-amqplib/php-amqplib/issues/622","repository_url":"https://api.github.com/repos/php-amqplib/php-amqplib","labels_url":"https://api.github.com/repos/php-amqplib/php-amqplib/issues/622/labels{/name}","comments_url":"https://api.github.com/repos/php-amqplib/php-amqplib/issues/622/comments","events_url":"https://api.github.com/repos/php-amqplib/php-amqplib/issues/622/events","html_url":"https://github.com/php-amqplib/php-amqplib/issues/622","id":381577843,"node_id":"MDU6SXNzdWUzODE1Nzc4NDM=","number":622,"title":"Endless loop after broken connection with rabbitmq in AMQPReader::rawread because of zero timeout","user":{"login":"programmer512","id":2909851,"node_id":"MDQ6VXNlcjI5MDk4NTE=","avatar_url":"https://avatars3.githubusercontent.com/u/2909851?v=4","gravatar_id":"","url":"https://api.github.com/users/programmer512","html_url":"https://github.com/programmer512","followers_url":"https://api.github.com/users/programmer512/followers","following_url":"https://api.github.com/users/programmer512/following{/other_user}","gists_url":"https://api.github.com/users/programmer512/gists{/gist_id}","starred_url":"https://api.github.com/users/programmer512/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/programmer512/subscriptions","organizations_url":"https://api.github.com/users/programmer512/orgs","repos_url":"https://api.github.com/users/programmer512/repos","events_url":"https://api.github.com/users/programmer512/events{/privacy}","received_events_url":"https://api.github.com/users/programmer512/received_events","type":"User","site_admin":false},"labels":[{"id":324546188,"node_id":"MDU6TGFiZWwzMjQ1NDYxODg=","url":"https://api.github.com/repos/php-amqplib/php-amqplib/labels/bug","name":"bug","color":"e11d21","default":true}],"state":"open","locked":false,"assignee":{"login":"lukebakken","id":514926,"node_id":"MDQ6VXNlcjUxNDkyNg==","avatar_url":"https://avatars2.githubusercontent.com/u/514926?v=4","gravatar_id":"","url":"https://api.github.com/users/lukebakken","html_url":"https://github.com/lukebakken","followers_url":"https://api.github.com/users/lukebakken/followers","following_url":"https://api.github.com/users/lukebakken/following{/other_user}","gists_url":"https://api.github.com/users/lukebakken/gists{/gist_id}","starred_url":"https://api.github.com/users/lukebakken/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lukebakken/subscriptions","organizations_url":"https://api.github.com/users/lukebakken/orgs","repos_url":"https://api.github.com/users/lukebakken/repos","events_url":"https://api.github.com/users/lukebakken/events{/privacy}","received_events_url":"https://api.github.com/users/lukebakken/received_events","type":"User","site_admin":false},"assignees":[{"login":"lukebakken","id":514926,"node_id":"MDQ6VXNlcjUxNDkyNg==","avatar_url":"https://avatars2.githubusercontent.com/u/514926?v=4","gravatar_id":"","url":"https://api.github.com/users/lukebakken","html_url":"https://github.com/lukebakken","followers_url":"https://api.github.com/users/lukebakken/followers","following_url":"https://api.github.com/users/lukebakken/following{/other_user}","gists_url":"https://api.github.com/users/lukebakken/gists{/gist_id}","starred_url":"https://api.github.com/users/lukebakken/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lukebakken/subscriptions","organizations_url":"https://api.github.com/users/lukebakken/orgs","repos_url":"https://api.github.com/users/lukebakken/repos","events_url":"https://api.github.com/users/lukebakken/events{/privacy}","received_events_url":"https://api.github.com/users/lukebakken/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/php-amqplib/php-amqplib/milestones/8","html_url":"https://github.com/php-amqplib/php-amqplib/milestone/8","labels_url":"https://api.github.com/repos/php-amqplib/php-amqplib/milestones/8/labels","id":3824251,"node_id":"MDk6TWlsZXN0b25lMzgyNDI1MQ==","number":8,"title":"2.8.2","description":"","creator":{"login":"lukebakken","id":514926,"node_id":"MDQ6VXNlcjUxNDkyNg==","avatar_url":"https://avatars2.githubusercontent.com/u/514926?v=4","gravatar_id":"","url":"https://api.github.com/users/lukebakken","html_url":"https://github.com/lukebakken","followers_url":"https://api.github.com/users/lukebakken/followers","following_url":"https://api.github.com/users/lukebakken/following{/other_user}","gists_url":"https://api.github.com/users/lukebakken/gists{/gist_id}","starred_url":"https://api.github.com/users/lukebakken/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lukebakken/subscriptions","organizations_url":"https://api.github.com/users/lukebakken/orgs","repos_url":"https://api.github.com/users/lukebakken/repos","events_url":"https://api.github.com/users/lukebakken/events{/privacy}","received_events_url":"https://api.github.com/users/lukebakken/received_events","type":"User","site_admin":false},"open_issues":2,"closed_issues":2,"state":"open","created_at":"2018-11-15T12:30:49Z","updated_at":"2018-11-17T13:42:01Z","due_on":null,"closed_at":null},"comments":2,"created_at":"2018-11-16T12:22:19Z","updated_at":"2018-11-17T13:42:35Z","closed_at":null,"author_association":"NONE","body":"OS: Ubuntu 14.04.2 LTS\r\nKernel verion: 3.16.0-30-generic\r\nphp version:: PHP 7.1.12-3+ubuntu14.04.1+deb.sury.org+1 (cli) \r\nphp-amqplib version: 2.8.1\r\n\r\nwe use VPN  connection in order to connect to our rabbitmq server. \r\nlets consider an example of code:\r\n\r\n       $connection = new \\PhpAmqpLib\\Connection\\AMQPConnection('xx.xx.xx.xx', '5672','test','test', \r\n        '/',false,\"AMQPLAIN\", null,\"en_US\",3.0,3.0,null,false,0);\r\n\r\n        sleep(10);  //during this time we can drop a connection to rabbitmq (stop vpn connection)\r\n\r\n        $connection->channel()->basic_consume('amq.rabbitmq.reply-to', '', false, true, false, false, function (\\PhpAmqpLib\\Message\\AMQPMessage $message) {});\r\n\r\n\r\n\r\ni can see that this script never stopped, because it hangs inside the loop in AMQPReader::rawread:\r\n\r\n           protected function rawread($n)\r\n            {\r\n             ......\r\n                    while (true) {\r\n                        $this->wait();\r\n                        try {\r\n                            $res = $this->io->read($n);\r\n                            break;\r\n                        } catch (AMQPTimeoutException $e) {\r\n                            if ($this->getTimeout() > 0) {\r\n                                throw $e;\r\n                            }\r\n                        }\r\n                    }\r\n                    $this->offset += $n;\r\n                    return $res;\r\n                \r\n                ......\r\n            }\r\n`\r\n\r\nthis is because $this->getTimeout()  equal to zero and AMQPTimeoutException is not thrown to the upper level in this case.\r\n**fwrite** are not fail in this case and successfully write bytes to such socket. \r\n **fread** inside **StreamIO::read($len)** always returns an empty string \"\" for such broken socket\r\n\r\nThis happens when we are waiting for a response from rabbitmq, in my concrete situations we are waiting for \"basic.consume_ok\". But this situation can be happened to any other types of commands when we need to wait a response from rabbitmq and we do not have a timeouts for them\r\n\r\nThanks in advance."},"comment":{"url":"https://api.github.com/repos/php-amqplib/php-amqplib/issues/comments/439617866","html_url":"https://github.com/php-amqplib/php-amqplib/issues/622#issuecomment-439617866","issue_url":"https://api.github.com/repos/php-amqplib/php-amqplib/issues/622","id":439617866,"node_id":"MDEyOklzc3VlQ29tbWVudDQzOTYxNzg2Ng==","user":{"login":"lukebakken","id":514926,"node_id":"MDQ6VXNlcjUxNDkyNg==","avatar_url":"https://avatars2.githubusercontent.com/u/514926?v=4","gravatar_id":"","url":"https://api.github.com/users/lukebakken","html_url":"https://github.com/lukebakken","followers_url":"https://api.github.com/users/lukebakken/followers","following_url":"https://api.github.com/users/lukebakken/following{/other_user}","gists_url":"https://api.github.com/users/lukebakken/gists{/gist_id}","starred_url":"https://api.github.com/users/lukebakken/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lukebakken/subscriptions","organizations_url":"https://api.github.com/users/lukebakken/orgs","repos_url":"https://api.github.com/users/lukebakken/repos","events_url":"https://api.github.com/users/lukebakken/events{/privacy}","received_events_url":"https://api.github.com/users/lukebakken/received_events","type":"User","site_admin":false},"created_at":"2018-11-17T13:42:35Z","updated_at":"2018-11-17T13:42:35Z","author_association":"COLLABORATOR","body":"A workaround would be to pass `true` to `$nowait` and wait on the channel yourself, passing a `timeout` argument."}}
{"actor":{"display_login":"lukebakken"}}