The business process is like this. our php Server uses socket to connect to the other server, and the other server will send messages to our php server from time to time. Therefore, we need to read the php server all the time, at the same time, you also need to send a heartbeat to each other every three minutes. When php keeps reading, the other party does not send a message... the business process is like this. our php Server uses socket to connect to the other server, and the other server will send messages to our php server from time to time. Therefore, we need to read the php server all the time, at the same time, you also need to send a heartbeat to the other party every three minutes. When php keeps reading and the other party does not receive any message, php is always waiting, how can I ensure a heartbeat every three minutes?
Reply content:
The business process is like this. our php Server uses socket to connect to the other server, and the other server will send messages to our php server from time to time. Therefore, we need to read the php server all the time, at the same time, you also need to send a heartbeat to the other party every three minutes. When php keeps reading and the other party does not receive any message, php is always waiting, how can I ensure a heartbeat every three minutes?
Generally, php is not recommended.
3-minute sleep delay (3)
Always execute the script set_time_limit (0)
Disconnect from the client and continue executing ignore_user_abort (0)
You can consider using swoole
You also need to send heartbeat to it when you read it. use php-cli to do it.
Swoole can easily meet your needs