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

Unable to establish SSL connection with Pawl #18

Closed
slowbro opened this issue May 13, 2015 · 8 comments
Closed

Unable to establish SSL connection with Pawl #18

slowbro opened this issue May 13, 2015 · 8 comments

Comments

@slowbro
Copy link

slowbro commented May 13, 2015

Hi again, cboden. I'm having issues connecting to wss:// sockets with Pawl on a new machine. I've been banging my head against this for about 6 hours now to no avail.

I'm starting with a brand new install of Pawl, using the test script provided, connecting to "wss://echo.websocket.org":

<?php

    require __DIR__ . '/vendor/autoload.php';

    $loop = React\EventLoop\Factory::create();
    $connector = new Ratchet\Client\Factory($loop);

    $connector('wss://echo.websocket.org')->then(function(Ratchet\Client\WebSocket $conn) {
        $conn->on('message', function($msg) {
            echo "Received: {$msg}\n";
        });

        $conn->send('Hello World!');
    }, function($e) use ($loop) {
        echo "Could not connect: {$e->getMessage()}\n";
        $loop->stop();
    });

    $loop->run();

composer deets:

[slowbro@slowbro test]$ cat composer.json
{
    "require" : {
        "ratchet/pawl": "dev-master"
    }
}
[slowbro@slowbro test]$ composer show -i
cboden/ratchet           v0.3.2             PHP WebSocket library
evenement/evenement      v2.0.0             Ãvénement is a very simple event dispatching library for PHP
guzzle/common            v3.9.2             Common libraries used by Guzzle
guzzle/http              v3.9.2             HTTP libraries used by Guzzle
guzzle/parser            v3.9.2             Interchangeable parsers used by Guzzle
guzzle/stream            v3.9.2             Guzzle stream wrapper component
ratchet/pawl             dev-master 3ba8d56 Asynchronous WebSocket client
react/cache              v0.4.0             Async caching.
react/dns                v0.4.1             Async DNS resolver.
react/event-loop         v0.4.1             Event loop abstraction layer that libraries can use for evented I/O.
react/promise            v2.2.0             A lightweight implementation of CommonJS Promises/A for PHP
react/socket             v0.4.2             Library for building an evented socket server.
react/socket-client      v0.4.3             Async connector to open TCP/IP and SSL/TLS based connections.
react/stream             v0.4.2             Basic readable and writable stream interfaces that support piping.
symfony/event-dispatcher v2.6.7             Symfony EventDispatcher Component
symfony/http-foundation  v2.6.7             Symfony HttpFoundation Component
symfony/routing          v2.6.7             Symfony Routing Component

php deets

[slowbro@slowbro test]$ php -v
PHP 5.6.8 (cli) (built: Apr 16 2015 14:54:09)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies
    with Xdebug v2.3.2, Copyright (c) 2002-2015, by Derick Rethans
[slowbro@slowbro test]$ php -m
[PHP Modules]
bz2
calendar
Core
ctype
curl
date
dom
ereg
exif
fileinfo
filter
ftp
gettext
hash
iconv
json
libxml
mbstring
mhash
mysql
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
readline
Reflection
session
shmop
SimpleXML
sockets
SPL
sqlite3
standard
sysvmsg
sysvsem
sysvshm
tokenizer
wddx
xdebug
xml
xmlreader
xmlwriter
xsl
zip
zlib

[Zend Modules]
Xdebug

OS deets

[slowbro@slowbro test]$ uname -a
Linux slowbro.org 2.6.32-431.29.2.el6.x86_64 #1 SMP Tue Sep 9 21:36:05 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
[slowbro@slowbro test]$ cat /etc/redhat-release
CentOS release 6.6 (Final)
[slowbro@slowbro test]$ openssl version
OpenSSL 1.0.1e-fips 11 Feb 2013

What seems to happen is that when connecting, it just hangs. like so..

# USING ws://
[slowbro@slowbro test]$ php test.php
Received: Hello World!
^C

# USING wss://
[slowbro@slowbro test]$ php test.php
#... HANGS FOREVER WITHOUT OUTPUT ...

I'm at a complete loss here. From my debugging it looks like the steam_get_contents in vendor/react/socket-client/src/SecureStream.php handleData is blocking.. but the stream is set to be nonblocking?

I'm so confuse-frustrated :(
@slowbro
Copy link
Author

slowbro commented May 13, 2015

This probably belongs in the socket-client project, as it seems to be what's killing the whole deal (even using Devistro/phpws..)

@slowbro
Copy link
Author

slowbro commented May 13, 2015

More info, because I hate sleep:

This works if I downgrade to react/socket-client 0.4.2 EXCEPT for this change:
reactphp-legacy/socket-client@3cc2bfd

compsison:
reactphp-legacy/socket-client@v0.4.2...v0.4.3

edit: AND, holy shit, they fixed the original bug: https://bugs.php.net/bug.php?id=41631
from our original conversation.. reactphp-legacy/socket-client#24

@onekit
Copy link

onekit commented May 13, 2015

Did you have connected with your WSS without pawl with regular browser to make sure is WSS is done and work properly?

I guess WSS not configured.

@slowbro
Copy link
Author

slowbro commented May 13, 2015

Yep. This is connecting to a known-good WSS.

@cboden
Copy link
Member

cboden commented May 13, 2015

I pushed a change to socket-client master that should provide a fix for PHP version 5.6.8. I'm still working on fixing other versions but if you can force that branch see if that fixes your issue for now.

@slowbro
Copy link
Author

slowbro commented May 14, 2015

Yeah, that seems to fix it. I receive the echo back from the wss:// connection with socket-client dev-master.

@slowbro
Copy link
Author

slowbro commented May 14, 2015

Coincidentally, that branch also fixes another bug with stream_get_contents hanging with Slack again for some reason.. working 100% now! Thanks @cboden, you're the best <3

@cboden
Copy link
Member

cboden commented May 14, 2015

Happy to help @slowbro. The amount of debug info you provide makes my life so much easier! :-)

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

No branches or pull requests

3 participants