walkor / GatewayWorker

Distributed realtime messaging framework based on workerman.
MIT License
1.01k stars 294 forks source link

Operation timeout in Lib\Gateway sendAndRecv method #100

Open Kulaxyz opened 1 year ago

Kulaxyz commented 1 year ago

https://github.com/walkor/GatewayWorker/blob/aefdc21fdf847331a5acbd7e4422cd26d44e5474/src/Lib/Gateway.php#L1157

Under a high load workers turn to a busy state after this exception in sendAndRecv method

stream_socket_client(): unable to connect to tcp://127.0.0.1:2313 (Operation timed out) in GatewayWorker/Lib/Gateway.php on line 1157

Linux kernel is optimized based on a manual.

I believe the problem is that the connection is closed every time and needs to be open on each new message, because of a getSession method call

I also noticed that some other calls of stream_socket_client() have STREAM_CLIENT_PERSISTENT flag, but this one does not.

Is it possible to have long-lasting connections here, since it would dramatically increase a performance? If not, how can we prevent this timeout errors?

walkor commented 1 year ago

Please update file https://github.com/walkor/GatewayWorker/blob/master/src/Lib/Gateway.php which use persistent connections for Gateways and workers communication. If that works for you I will release a new version later.