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

Unhandled method frame Bunny\Protocol\MethodConnectionCloseFrame #20

Closed
pprishchepa opened this issue Feb 12, 2016 · 10 comments
Closed

Comments

@pprishchepa
Copy link

I faced with an Exception sometimes

'Bunny\Exception\ClientException' with message 'Unhandled method frame Bunny\Protocol\MethodConnectionCloseFrame.' in ~/.composer/vendor/bunny/bunny/src/Bunny/AbstractClient.php:410

What does it mean and how can I avoid it?

@jakubkulhan
Copy link
Owner

Can you provide context what you were doing (opening connection, creating channel, declaring queue/exchange, consuming/publishing messages, ...) - some code that could replicate the issue? I suppose RabbitMQ did not like something you did and therefore tried to close the whole connection with all channels.

If you open up a pull request with AbstractClient throwing more descriptive ClientException for MethodConnectCloseFrame using its $replyCode & $replyText, I'll be happy to merge it.

@pprishchepa
Copy link
Author

I can't provide more context, because the issue somewhere inside event loop... I will try to give more info.

The issue reproduced when RabbitMQ server located far from client and message rate is about 20 per seconds. In my case, server located in Canada, client in Russia, Novosibirsk.

Everything Ok when server and client on the same machine even message rate more than 500/per seconds.

May be it helps

exception 'Bunny\Exception\ClientException' with message 'Unhandled method frame Bunny\Protocol\MethodConnectionCloseFrame.' in ~/.composer/vendor/bunny/bunny/src/Bunny/AbstractClient.php:410 Stack trace: #0 ~/.composer/vendor/bunny/bunny/src/Bunny/Async/Client.php(303): Bunny\AbstractClient->onFrameReceived(Object(Bunny\Protocol\MethodConnectionCloseFrame)) #1 [internal function]: Bunny\Async\Client->onDataAvailable(Resource id #812, Object(React\EventLoop\StreamSelectLoop)) #2 ~/.composer/vendor/react/event-loop/StreamSelectLoop.php(227): call_user_func(Array, Resource id #812, Object(React\EventLoop\StreamSelectLoop)) #3 ~/.composer/vendor/react/event-loop/StreamSelectLoop.php(201): React\EventLoop\StreamSelectLoop->waitForStreamActivity(1261205.9116364) #4 worker.php(52): React\EventLoop\StreamSelectLoop->run()

@pprishchepa
Copy link
Author

Is it possible server close connection by some reasons?

@jakubkulhan
Copy link
Owner

I've committed change that when connection.close frame is received, thrown exception has more descriptive message. It should give us clue why is server closing connection, please try dev-master.

@pprishchepa
Copy link
Author

It's great, thank you.

Now I faced with an Exception.
exception 'Bunny\Exception\ClientException' with message 'Broken pipe or closed connection.' in ~/.composer/vendor/bunny/bunny/src/Bunny/AbstractClient.php:280

It looks like network issue. Can you recommend some tuning of bunny config? But probably I need to tune something on server-side.

In any case, thanks you for your helpful and for the great library. By the way, we use it in production in our startup https://wodby.com/

@ondrejmirtes
Copy link
Contributor

Try to look at this: https://www.rabbitmq.com/networking.html

Also, make sure that Bunny is sending the Heartbeat frame according to the
"heartbeat" parameter setting. RabbitMQ can still drop the connection
because sometimes the consumer is performing an expensive operation that
takes longer than the heartbeat interval and RabbitMQ considers the
connection as dead.

After you perform the maximum amount of tuning you're able to do, I
recommend catching ClientException and restarting the consumer when it
occurs.

On Thursday, February 18, 2016, Pavel Prischepa notifications@github.com
wrote:

It's great, thank you.

Now I faced with an Exception.
exception 'Bunny\Exception\ClientException' with message 'Broken pipe or
closed connection.' in
~/.composer/vendor/bunny/bunny/src/Bunny/AbstractClient.php:280

It looks like network issue. Can you recommend some tuning of bunny
config? But probably I need to tune something on server-side.

In any case, thanks you for your helpful and for the great library. By the
way, we use it in production in our startup https://wodby.com/


Reply to this email directly or view it on GitHub
#20 (comment).

Ondřej Mirtes

@jakubkulhan
Copy link
Owner

As pointed out by @ondrejmirtes, the most common problem is that heartbeat frame does not get a chance to be sent. You can change heartbeat like this:

$client = new \Bunny\Client([..., "heartbeat" => 180.0 /* 3 minutes */, ...]); //

Heartbeat timeout must be long enough that any blocking operation in consume callback finishes within the specified timeout.

Btw. Wodby looks great! Keep up :)

@pprishchepa
Copy link
Author

@jakubkulhan and @ondrejmirtes many thanks for your recomendations, I'll check both server and client side.

Also I've catched an Exception by using patch. It looks like we catch a strange issue :). Is it possible FRAME_ERROR relates to network error too?

'Bunny\Exception\ClientException' with message 'Connection closed by server: FRAME_ERROR - type 3, first 16 octets = <<"{\"type\":\"result\"">>: {invalid_frame_end_marker, 13}' in ~/.composer/vendor/bunny/bunny/src/Bunny/AbstractClient.php:412

@jakubkulhan
Copy link
Owner

I think it's possible that packets get broken, AMQP does not have any built-in checksumming mechanism, however, this should be handled on TCP layer.

@alexey-kruchenok
Copy link

I got this situation when by mistake i tried to send to exchange that did not exist, i think is good to add more meaningfull error

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

4 participants