Skip to content
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

[BUG]: Remove broken sockets from socket collection if write request fails #61

Closed
hollodotme opened this issue Aug 11, 2020 · 2 comments · Fixed by #62
Closed

[BUG]: Remove broken sockets from socket collection if write request fails #61

hollodotme opened this issue Aug 11, 2020 · 2 comments · Fixed by #62
Assignees
Labels
Milestone

Comments

@hollodotme
Copy link
Owner

Expected Behavior

When the attempt to write to a socket fails, because the socket is already closed, blocked or terminated, this socket must be removed from the socket collection, so subsequent requests will open new sockets for processing.

Actual Behavior

The broken socket is not removed from the socket collection and the client tries to reuse the broken socket for subsequent requests.

Steps to Reproduce the Problem

  1. Send a request
  2. Kill the underlying php-fpm child process
  3. Send a second request (Raises a WriteFailedException here https://github.com/hollodotme/fast-cgi-client/blob/v3.1.2/src/Sockets/Socket.php#L410)
  4. Send a third request, it uses the same socket as the second request, which is broken

Specifications

  • Package version: v3.1.2
  • PHP version: >= 7.1

Further comments

This issue emerged from brefphp/bref#713.

@hollodotme hollodotme added the bug label Aug 11, 2020
@hollodotme hollodotme added this to the v3.1.3 milestone Aug 11, 2020
@hollodotme hollodotme self-assigned this Aug 11, 2020
@Nyholm
Copy link

Nyholm commented Aug 12, 2020

Does it make sense to also retry to write to a new socket? Or should that be handled by the caller?

@hollodotme
Copy link
Owner Author

There is no retrying mechanism at all in the client right now and even though it's probably not hard to implement in that case, I'd like to leave this responsibility to the caller/user. This also would be a BC break, because callers won't get notified (by an exception) about broken streams anymore and an automatic retry is not what everyone wants in that case.

But I also understand that a retry can totally make sense and would reduce efforts on the user's end. I do think about prefixed methods which will add a retry mechanism when sending requests, like: Client#retryRequest($connection, $request, $maxRetries = 5) and Client#retryAsyncRequest($connection, $request, $maxRetries = 5). This way the user can choose to use retry or not, it would be a clear new feature (no BC break), it would seperate concerns of the client's methods. Anyway, this should not be part of this issue, but a new feature request. (-:

I'm trying to fix this bug by today and release v3.1.3. 🤞

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants