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

No answer from server #40

Closed
kimberli-opium opened this issue May 26, 2019 · 2 comments
Closed

No answer from server #40

kimberli-opium opened this issue May 26, 2019 · 2 comments
Assignees
Milestone

Comments

@kimberli-opium
Copy link

Expected Behavior

An error message/exception and correct work finishing of the server, if responses cannot be handled.

Actual Behavior

No answer from the server, because a client has unhandled responses, but it cannot be handled.

Specifications

  • Package version: 2.7.1
  • PHP version: 7.2.9
  • Platform/OS: macOS

Further comments

Fpm-server configuration has the number of child processes pm.max_children = 3.
The problem occurs, if the number of concurrently sent processes is above pm.max_children. I send concurrently five PostRequests to the fpm-server via hollodotme\FastCGI\Client. The server receives all requestIds and stores them. First three requests are successfully processed. The last two are only stored, but aren’t handled. No exception is shown. The server can’t finish a script execution.

$client = new Client(new NetworkSocket('fpm', 9000));

$responseCallback = static function (ProvidesResponseData $response) {
    echo $response->getBody().' from callback!'."\n";
};

$failureCallback = static function (Throwable $throwable) {
    echo $throwable->getMessage().' fail'."\n";
};

$requestIds = [];

for ($i = 0; $i < 5; $i++) {
    $request = new PostRequest('/www/script/testTask.php', http_build_query(['key' => $i]));

    $request->addResponseCallbacks($responseCallback);
    $request->addFailureCallbacks($failureCallback);

    $requestId = $client->sendAsyncRequest($request);
    $requestIds[$requestId] = $requestId;
}

echo 'Sent requests with IDs: ' . implode(', ', $requestIds) . "\n";

while ($client->hasUnhandledResponses())
{
    $client->handleReadyResponses(3000);
}
@theseer
Copy link

theseer commented May 27, 2019

I can reproduce this on my local box (fedora 30) with FPM on PHP 7.3, PHP 7.2 and PHP 7.1. So at least it's nothing where the FPM changes had any effect.

Switching to UnixDomainSocket does not change the observed behavior, either.

@hollodotme
Copy link
Owner

To also document it here:

The root cause of this behavior was the change to re-using idle sockets in v2.7.0. This caused the socket connections to remain open after they provided a response to an async request.
If the pm.max_children setting allows a number of 3 for example the 4th parallel async request (and all further requests) was not processed anymore as the 3 child processes were already occupied by the 3 open socket connections.

The fix was to close & remove sockets of async requests after they have responded.

The fix was merged in f09beca

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

No branches or pull requests

3 participants