Skip to content

Resolving raises an error in the Stream component #13

Description

@clue

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

Activity

  1. jeremykendall commented on Dec 3, 2014

    @jeremykendall

    👍

    Thanks for digging into this.

  2. miladr commented on Dec 3, 2014

    @miladr

    👍

  3. andig commented on Jan 5, 2015

    @andig

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

  4. modified the milestone: on Feb 24, 2016
  5. clue commented on Feb 12, 2017

    @clue
    MemberAuthor

    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.

  6. modified the milestones: v0.4.4, on Feb 12, 2017
  7. self-assigned this
    on Feb 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions