socket icon indicating copy to clipboard operation
socket copied to clipboard

stream_socket_client throws fatal error if network is unreachable

Open valzargaming opened this issue 2 months ago • 2 comments

https://github.com/reactphp/socket/blob/def0730288b2a321db04f22caf86259ab2975cc7/src/TcpConnector.php#L91

This should be handled more gracefully by returning with a rejected promise if it fails to connect.

valzargaming avatar Oct 24 '25 17:10 valzargaming

@valzargaming Thanks for reporting, I'm still trying to understand what's going on here. The stream_socket_client() function never throws on its own, it only reports an E_WARNING on error or reports a SO_ERROR later on the socket. Both of these error classes are handled by the code following the stream_socket_client() function and the entire code has 100% code coverage including any errors cases.

  1. Can you help us reproduce the problem you're seeing?

  2. Specifically, please provide a gist that allows us the see the error you're seeing.

  3. Could this perhaps be related to a custom error handling (set_error_handler() function like #290)? If so, what does it look like and what makes you think this is an error in ReactPHP rather than the custom error handler?

Thank you.

clue avatar Oct 25 '25 18:10 clue

I'll take a closer look at this later this week, but I believe 3 is the likely culprit.

valzargaming avatar Oct 28 '25 01:10 valzargaming