This is the line of error that PHP sends me. The connection is open, trying to write to the socket and on the server side everything falls. All the Internet has dug over what it can be, how to heal. In general, there is an idea to create an additional service that will monitor this socket server and raise it if it falls, but I would like to understand how to avoid this error altogether. And yes, the little dog before fwrite () decides everything, but it is not clear where the data will go.
1 answer
The error "broken pipe" means that you are trying to write to a channel that was closed on the other side. In other words, the client has already fallen off - and the server is still trying to transmit some information to it (or vice versa).
On the server side, such an error must be handled (use try / catch) - because the loss of the connection with the client should not lead to a server crash.
But the root cause of the error is in the fallen off client.
- Here Pavel did not find a single intelligible answer, thank you. Because of what this can happen, the connection is broken or the client is not responding, what should? I just want to understand how to react, after the error, delete the connection on the server or try to use it again? - Sergey
- Delete, of course. How do you reuse a broken connection? - Pavel Mayorov
- And why the same error gets out when working with a pair of sockets created by the stream_socket_pair () function - Sergey
- Because one of the sockets is closed. - Pavel Mayorov
|