Closed
Description
Resolving any name raises an error in the Stream component:
Warning: feof(): 60 is not a valid stream resource in .. /src/Socket/Connection.php on line 18
This happens because this component uses the React\Socket\Connection
class instead of the React\Stream\Stream
class.
Originally reported in: reactphp/socket#4
Documentation bug: reactphp/socket#13
See also: #11
The following is copied from reactphp/socket#4, originally reported by @jeremykendall
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 php dns.php jeremykendall.net returned:
$ php dns.php jeremykendall.net
Host: 50.57.159.57
PHP Warning: feof(): 33 is not a valid stream resource in /Users/jeremykendall/dev/explore-react/vendor/react/react/src/Socket/Connection.php on line 18
PHP Stack trace:
PHP 1. {main}() /Users/jeremykendall/dev/explore-react/dns.php:0
PHP 2. React\EventLoop\StreamSelectLoop->run() /Users/jeremykendall/dev/explore-react/dns.php:17
PHP 3. React\EventLoop\StreamSelectLoop->waitForStreamActivity() /Users/jeremykendall/dev/explore-react/vendor/react/react/src/EventLoop/StreamSelectLoop.php:201
PHP 4. call_user_func:{/Users/jeremykendall/dev/explore-react/vendor/react/react/src/EventLoop/StreamSelectLoop.php:227}() /Users/jeremykendall/dev/explore-react/vendor/react/react/src/EventLoop/StreamSelectLoop.php:227
PHP 5. React\Socket\Connection->handleData() /Users/jeremykendall/dev/explore-react/vendor/react/react/src/EventLoop/StreamSelectLoop.php:227
PHP 6. feof() /Users/jeremykendall/dev/explore-react/vendor/react/react/src/Socket/Connection.php:18
Warning: feof(): 33 is not a valid stream resource in /Users/jeremykendall/dev/explore-react/vendor/react/react/src/Socket/Connection.php on line 18
Call Stack:
0.0002 238968 1. {main}() /Users/jeremykendall/dev/explore-react/dns.php:0
0.0060 906616 2. React\EventLoop\StreamSelectLoop->run() /Users/jeremykendall/dev/explore-react/dns.php:17
0.0062 907648 3. React\EventLoop\StreamSelectLoop->waitForStreamActivity() /Users/jeremykendall/dev/explore-react/vendor/react/react/src/EventLoop/StreamSelectLoop.php:201
0.0515 908184 4. call_user_func:{/Users/jeremykendall/dev/explore-react/vendor/react/react/src/EventLoop/StreamSelectLoop.php:227}() /Users/jeremykendall/dev/explore-react/vendor/react/react/src/EventLoop/StreamSelectLoop.php:227
0.0515 908312 5. React\Socket\Connection->handleData() /Users/jeremykendall/dev/explore-react/vendor/react/react/src/EventLoop/StreamSelectLoop.php:227
0.0527 913368 6. feof() /Users/jeremykendall/dev/explore-react/vendor/react/react/src/Socket/Connection.php:18
Environment:
Mac OS X 10.9.4
PHP 5.5.12
React 0.4.1
$ php -v
PHP 5.5.12 (cli) (built: May 23 2014 15:03:24)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
with Xdebug v2.2.4, Copyright (c) 2002-2014, by Derick Rethans