-
Notifications
You must be signed in to change notification settings - Fork 1k
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
queue_declare silently returning null on timeout #1101
Comments
Thanks for reporting! I guess it's because to You have default value for channel RPC timeout. 0 is special case when waiting for network frames. It is being converted to null timeout when executing It's really hard to tell why Anyways, I don't think You want to block your code indefinitely :) It would be good practice to use appropriate timeouts. We will change default values in next major version, once we start work on it. BTW, You forgot to mention PHP version. [1] https://www.php.net/manual/en/function.stream-select.php |
Thanks for the quick response. We're still on php 7.4.33. I'll try specifying the channel RPC timeout and get back to you tomorrow. |
Seems like setting the channel RPC timeout to a non-zero value was the right call, this problem is gone now. Thanks for the help! |
Version(s) affected: 3.5.2 (probably all)
Description
AMQPChannel::declare_queue()
returnsnull
($no_wait
flag is set tofalse
) in case the read for the response timed out.How to reproduce
Don't really have a reproducer here, we have a lot of php processes running and currently have trouble with some timeouts (cause tbd) and also some errors because we expect an array with the queue name to be returned from
queue_declare
, but we don't get the array built byqueue_declare_ok
butnull
instead.I've been digging through the code and the only way I see how
AbstractChannel::wait()
could returnnull
is by either the dispatched method returningnull
(butqueue_declare_ok
never returnsnull
) or if there is abreak
in thewhile (true)
thus ending the method, so thevoid
return is converted tonull
on assignment.There are two cases where
break
is used inside the loop:$non_blocking
is set totrue
-> not possible asqueue_declare
always callswait()
with$non_blocking = false
AMQPNoDataException
Possible Solution
As only the
AMQPNoDataException
remains, considering the comment in thecatch
-block, for blocking calls the exception should IMO be rethrown instead of just breaking out of the loop and thus "returning"null
, or the loop should justcontinue
.As a side note - I guess it makes sense to append an explicit
return null;
at the end of thewait()
method? I personally find methods returning eithervoid
ormixed
rather sketchy...Additional context
stream
connection typeThe text was updated successfully, but these errors were encountered: