Skip to content

Listening on same port twice does not fail on Windows #56

Closed

Description

@shaunbramley

Test suite for v0.4.4 fails on Windows, using both 5.6.29 and 7.0.13, with PHPUnit 4.8.31

PHPUnit 4.8.31 by Sebastian Bergmann and contributors.

...............F

Time: 21.31 seconds, Memory: 8.00MB

There was 1 failure:

1) React\Tests\Socket\ServerTest::testListenOnBusyPortThrows
Failed asserting that exception of type "React\Socket\ConnectionException" is thrown.

FAILURES!
Tests: 16, Assertions: 15, Failures: 1.

Edit: expanded information to include full phpunit output

Activity

  1. Nek- commented on Jan 6, 2017

    @Nek-

    @shaunbramley Thanks for reporting issue. Do you have some more information about ? Like "what happens if the exception is not throwned" ? And "how did you run test suite" (environment/terminal/etc) ?

  2. clue commented on Jan 7, 2017

    @clue
    Member

    @shaunbramley thanks for reporting! 👍

    Unfortunately I do not have a system to test this on, so I guess we could use some help to track this down.

    Which version of Windows has this been tested on, can others confirm this issue?

    The test essentially boils down to this:

    <?php
    
    $a = stream_socket_server('tcp://127.0.0.1:1337');
    $b = stream_socket_server('tcp://127.0.0.1:1337');

    See also https://3v4l.org/XjhRa

    Can you and/or anybody else verify this fails? Thanks! 👍

  3. shaunbramley commented on Jan 7, 2017

    @shaunbramley
    Author

    @clue - sorry for the delay. I've had my son all week. :)

    Some extended testing would seem to indicate that this might be a PHP issue.

    $host = '127.0.0.1';
    $port = '1234';
    
    $errno = 0;
    $errstr = '';
    
    $server = stream_socket_server("tcp://$host:$port", $errno, $errstr);
    if (false !== $server) {
        echo "$errno" . PHP_EOL;
        echo "$errstr" . PHP_EOL;
        echo "We're ok";
    }
    
    $another = stream_socket_server("tcp://$host:$port", $errno, $errstr);
    if (false === $another) {
        echo "$errno" . PHP_EOL;
        echo "$errstr" . PHP_EOL;
        echo "We're ok";
    }
    

    expected output:

    0
    
    We're ok
    0
    Address already in use
    We're ok
    

    Actual output:

    0
    
    We're ok
    

    Confirmed test suite works as expected on macOS Sierra w/ PHP 7.0.14 (via homebrew)

    @Nek- Windows 10 Pro, ran within Powershell (both as Administrator, and regular user). Steps to reproduce:

    1. git -b checkout dev-pin-phpunit-4.8 v0.4.4
    2. composer install
    3. composer require --dev phpunit/phpunit:4.8
    4. vendor/bin/phpunit

    Something else that would indicate that something is going on "under the hood" is that when executed on Windows is the time required for the test suite to execute. On windows the test suite takes ~20s; whereas on my macOS system it takes ~230ms.

  4. changed the title [-]Failed listening on busy port[/-] [+]Listening on same port twice does not fail on Windows[/+] on Jan 8, 2017
  5. clue commented on Jan 8, 2017

    @clue
    Member

    @shaunbramley thanks for reporting back and no worries, family time is precious :) 👍

    Thanks for the steps to reproduce this, I've updated the issue title and hope anybody else may have some ideas here 👍

  6. clue commented on Feb 5, 2017

    @clue
    Member

    I'd like to make this actionable in order to resolve / close this ticket. It looks like this may be a Windows-only issue, so we may also skip this test on affected versions.

    Does anybody else happen to have installed PHP on Windows and can help to reproduce the following does indeed not emit any errors?

    <?php
    $a = stream_socket_server('tcp://127.0.0.1:1337');
    $b = stream_socket_server('tcp://127.0.0.1:1337');

    Any input would be appreciated here 👍 (Please note Windows and PHP version)

  7. jsor commented on Feb 5, 2017

    @jsor
    Member

    I tested that on Windows 7 with PHP 5.6.30 and 7.1.1 and both do not emit an error but return a resource for $a and $b.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions