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

Feature request: set connection timeout #13

Merged
merged 3 commits into from Nov 8, 2012

Conversation

@narkq
Copy link
Contributor

narkq commented Nov 6, 2012

There is currently no way to set a connection timeout through the API.

This is really sad when you're trying to use AMQPQueue::consume in a web server environment. If you've got no messages in 5-10 seconds, most likely this request will be canceled by user, and it makes more sense to report a timeout than to hang there indefinitely waiting for a message. I know that AMQP 0.9.1 spec doesn't support connection timeouts, but I think this feature is important enough.

This pull request adds the following:

  • INI setting amqp.timeout
  • AMQPConnection::getTimeout method
  • AMQPConnection::setTimeout method. If connection is already established, timeout is set immediately. Otherwise, timeout is set next time connection is established.
  • timeout option for AMQPConnection::__construct
  • every method that reads from channel can throw AMQPConnectionException now
  • AMQPConnectionException::getCode returns an error code from librabbitmq
  • AMQP_OS_SOCKET_TIMEOUT_ERRNO constant to distinguish timeouts from any other connection error
@bkw

This comment has been minimized.

Copy link
Collaborator

bkw commented Nov 6, 2012

Wow! This adds functionality even missing from librabbitmq!
In the past I used pcntl_alarm() to abort consume calls, but handling this on the socket level is much nicer!
👍

pdezwart added a commit that referenced this pull request Nov 8, 2012
Feature request: set connection timeout
@pdezwart pdezwart merged commit 44faddf into pdezwart:master Nov 8, 2012
@bkw bkw mentioned this pull request Nov 13, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.