varspool / Wrench

A simple PHP WebSocket implementation for PHP 7.1
Do What The F*ck You Want To Public License
596 stars 210 forks source link

"Client connection closed" after handshake #72

Closed denis-galas closed 7 years ago

denis-galas commented 9 years ago

Hello. I'm trying to connect to my web socket server in PHP using your Client class. My code looks like this: $uri = 'ws://hb-main.localhost:8000/tix_count';

require_once DIR . '/class/WebSocket/SplClassLoader.php'; $classLoader = new SplClassLoader('Wrench', DIR . '/class/WebSocket'); $classLoader->register();

$client = new \Wrench\Client($uri, 'http://hb-main.localhost'); $connect = $client->connect();

But each time I'm disconnecting after handshake, so output looks like this: info: Wrench\ConnectionManager: Wrench\Connection: 127.0.0.1:56887 (f1b15ee4fbadbd982b0d120116984121d1d98114fec4e04c3c8c2f3d0927fb09e3bfe1ff82ed9a75d82a9752d050b39f0159e6ac0bd2dcd7a0b2ff8593e09981): Connected info: Wrench\ConnectionManager: Wrench\Connection: 127.0.0.1:56887 (f1b15ee4fbadbd982b0d120116984121d1d98114fec4e04c3c8c2f3d0927fb09e3bfe1ff82ed9a75d82a9752d050b39f0159e6ac0bd2dcd7a0b2ff8593e09981): Handshake successful: 127.0.0.1:56887 (f1b15ee4fbadbd982b0d120116984121d1d98114fec4e04c3c8c2f3d0927fb09e3bfe1ff82ed9a75d82a9752d050b39f0159e6ac0bd2dcd7a0b2ff8593e09981) connected to /tix_count notice: Wrench\ConnectionManager: Client connection closed: exception 'Wrench\Exception\CloseException' with message 'Error reading data from socket: Not connected' in /var/www/hb-main/inc/class/WebSocket/Wrench/Connection.php:396 Stack trace:

0 /var/www/hb-main/inc/class/WebSocket/Wrench/ConnectionManager.php(243): Wrench\Connection->process()

1 /var/www/hb-main/inc/class/WebSocket/Wrench/ConnectionManager.php(168): Wrench\ConnectionManager->processClientSocket(Resource id #34)

2 /var/www/hb-main/inc/class/WebSocket/Wrench/Server.php(198): Wrench\ConnectionManager->selectAndProcess()

3 /var/www/hb-main/inc/websocket/server.php(36): Wrench\Server->run()

4 {main}

warning: Wrench\ConnectionManager: Wrench\Connection: 127.0.0.1:56887 (f1b15ee4fbadbd982b0d120116984121d1d98114fec4e04c3c8c2f3d0927fb09e3bfe1ff82ed9a75d82a9752d050b39f0159e6ac0bd2dcd7a0b2ff8593e09981): Unable to send close message

Why it's happening? Can you please fix this or let me know if I'm making mistake somewhere in my code.

Thank you.

Alarmfifa commented 9 years ago

Could you check with a new version of Wrench? I saw this error message ('Error reading data from socket: Not connected' ) earlier but now I don't meet such problem. if it is actual. could you provide more info about your client behavior for reproducing. (how do you close your browser session, for example).