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
Warning: feof(): 60 is not a valid stream resource in .. /src/Socket/Connection.php on line 18 #4
Comments
I have the same error when the connection is closed from a A solution : detect the end of stream before dispatching if ('' === $data || false === $data || feof($stream)) {
$this->end();
} else {
$this->emit('data', array($data, $this));
} A temporary solution is to specify $conn->end(false); |
Would you be able to provide instructions on how to replicate this error? |
I got (almost) the same error this morning while working on the DNS basic usage example. Maybe this could help replicate the warning: <?php
// dns.php
error_reporting(PHP_INT_MAX);
require_once 'vendor/autoload.php';
$loop = \React\EventLoop\Factory::create();
$factory = new \React\Dns\Resolver\Factory();
$dns = $factory->create('8.8.8.8', $loop);
$dns->resolve($argv[1])
->then(
function ($ip) { echo "Host: $ip\n"; },
function ($e) { echo "Error: {$e->getMessage()}\n"; }
);
$loop->run(); Running
Environment:
|
The solution suggested by brieucthomas did work for me though I had to check for NULL data as well. |
Similar problem here running
Update: fix from @webzak confirmed working. |
Any chance this is gonna be fixed? Stumpes me every time I'm doing a composer install :( |
@jeremykendall, thanks for your script! We can now successfully reproduce this issue. I believe this to be an issue in the react/dns component. Would you care to report the error over in the corresponding project? This might also be the reason why @andig experiences the same issue in the react/http-client component. It uses the react/dns component to resolve hostnames to IPs. @andig, would you care to verify that this should work when you use IPs instead of hostnames? The underlying problem appears to be that the Does anybody else experience the same issue in a different context? |
Verified - this is my current workaround.
Does that mean that a new type of client connection needs to be developed now? Would this be goal of this issue then? |
@brieucthomas solution worked for me. No warning anymore. |
Thanks for the confirmation @andig. The Thanks for reporting back @miladr, would you care to also describe how to reproduce the issue you were having? See also my above comment for details. As it currently stands it appears to be caused by using |
You are welcome. I'm creating a Http testing tool for our project. <?php
require 'vendor/autoload.php';
$loop = React\EventLoop\Factory::create();
$dnsResolverFactory = new \React\Dns\Resolver\Factory();
$dnsResolver = $dnsResolverFactory->createCached('8.8.8.8', $loop);
$factory = new \React\HttpClient\Factory();
$client = $factory->create($loop, $dnsResolver);
foreach(range(1,10) as $index){
echo "Request #" . $index . " Had been sent at " . date("i:s",time()) . PHP_EOL;
$request = $client->request('GET', 'http://httpbin.org/get?index=' . $index);
$buffer = '';
$request->on(
'response',
function ($response) use (&$buffer) {
$response->on(
'data',
function ($data) use (&$buffer) {
$buffer .= $data;
}
);
}
);
$request->on(
'end',
function () use (&$buffer , $index) {
echo "Request #" . $index . " completed at " . date("i:s",time()) . PHP_EOL;
}
);
$request->end(false);
}
$loop->run(); |
I'm having my slow day. https://github.com/reactphp/dns/blob/master/src/Query/Executor.php uses
So this is the piece that needs to be fixed and is currently missing imho? |
I've forwarded this error report to the component that is actually the source of this error: Afaict this component does not need to be patched. Can we close this ticket? |
@clue I vote yes. Thanks for your hard work on this. |
@clue that's what I've meant- thank you! |
When data are short after reading with stream_socket_recvfrom() stream type changes from 'stream' to 'Unknown' and feof($stream) generates warning.
The possible fix is to add check of type before feof()
if ('' === $data || false === $data || get_resource_type($stream) == 'Unknown' || feof($stream))
The text was updated successfully, but these errors were encountered: