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

Resolving raises an error in the Stream component #13

Closed
clue opened this issue Dec 3, 2014 · 4 comments · Fixed by #45
Closed

Resolving raises an error in the Stream component #13

clue opened this issue Dec 3, 2014 · 4 comments · Fixed by #45
Assignees
Labels
Milestone

Comments

@clue
Copy link
Member

clue commented Dec 3, 2014

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
@jeremykendall
Copy link

👍

Thanks for digging into this.

@miladr
Copy link

miladr commented Dec 3, 2014

👍

@andig
Copy link

andig commented Jan 5, 2015

Any chance to get a fix for this? Do you need a PR?

@clue
Copy link
Member Author

clue commented Feb 12, 2017

For the reference: This bug has actually been addressed indirectly via reactphp/socket#51.

I've just filed #45 that updates the dependencies and adds some tests to verify this should no longer happen.

@clue clue modified the milestones: v0.4.4, v0.5 Feb 12, 2017
@clue clue self-assigned this Feb 12, 2017
@clue clue closed this as completed in #45 Feb 13, 2017
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.

4 participants