-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Socket causes connection timed out exception #4092
Comments
It seems like just putting the code inside Co\run(function () {}) is enough to cause the issue. Without Co\run: (runs perfectly)
With Co\run: (timeout)
Also, with \Swoole\Runtime::enableCoroutine(); then swoole won't allow running the code without putting it inside Co\run Note: compile swoole without the sockets support does seem to get around the connection timeout error. I still get some weird timeout when I try to run the whole code inside coroutine using my sample code in the first post of this thread, however. Note2: after re-compiling without the sockets support, I still get the connection timeout error when I try to run pheanstalk reserveWithTimeout inside Co\run. I'm quite sure this has something to do with swoole but not entirely sure how to debug or fix this. Note3: Further debugging seems to indicate that the below code (inside pheanstalk) is stalling at the socket_read:
Interesting enough, a similar method inside pheanstalk works fine:
|
I can confirm that, even when compiling swoole without sockets (or with it), trying to read socket with the default mode will always timeout: No sockets:
Code:
The timeout happens here inside pheanstalk as mentioned above in the previous post:
Running the code outside of Co\run does not result in that issue. What should I do? |
Hello, I know everyone is busy. Is there anything that I can do to make debugging easier? |
I can confirm that if I change the code from
to
Then I will not get the timeout issue. Any idea how to fix it? This code belongs to pheanstalk library and it works fine if swoole is not enabled. |
Okie, so the fixes I found are:
|
I'm using swoole with pheanstalk, if I enable the sockets extension (sockets.io) for PHP, then pheanstalk will automatically use socket to connect to beanstalk and will get connection timeout error
My code is rather long, so I will copy only the parts I think important, please let me know if I should copy more
I expect the socket to connect properly.
The connection timeout error.
On additional note, if I build swoole WITHOUT the socket option, and remove sockets extension from PHP, pheanstalk will automatically fall to use filesocket option, which results in another error:
I wonder if it is necessary to write a socket connection class for pheanstalk that utilize swoole socket instead of the default PHP socket?
php --ri swoole
)?swoole
Swoole => enabled
Author => Swoole Team team@swoole.com
Version => 4.6.4-dev
Built => Mar 11 2021 15:04:21
coroutine => enabled with boost asm context
epoll => enabled
eventfd => enabled
signalfd => enabled
cpu_affinity => enabled
spinlock => enabled
rwlock => enabled
sockets => enabled
openssl => OpenSSL 1.1.1j 16 Feb 2021
dtls => enabled
http2 => enabled
json => enabled
pcre => enabled
zlib => 1.2.11
mutex_timedlock => enabled
pthread_barrier => enabled
futex => enabled
async_redis => enabled
Directive => Local Value => Master Value
swoole.enable_coroutine => On => On
swoole.enable_library => On => On
swoole.enable_preemptive_scheduler => Off => Off
swoole.display_errors => On => On
swoole.use_shortname => On => On
swoole.unixsock_buffer_size => 8388608 => 8388608
uname -a
&php -v
&gcc -v
) ?Linux lead-dev-0 4.15.0-117-generic #118-Ubuntu SMP Fri Sep 4 20:02:41 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
The text was updated successfully, but these errors were encountered: