When i try to connect to WebSocket server from the client, the connection is stablished but the server respond with the following error Error during WebSocket handshake: Unexpected response code: 426
I'm using autobahn js from client side, but i tested the connection from Simple Websocket Client and websocket and same thing appened.
My server code:
<?php
use React\EventLoop\Factory;
use React\ZMQ\Context;
use React\Socket\Server;
use Ratchet\Http\HttpServer;
use Project\Socket\Pusher;
use Ratchet\WebSocket\WsServer;
use Ratchet\Wamp\WampServer;
use Ratchet\Server\IoServer;
$loop = Factory::create();
$pusher = new Pusher;
$context = new Context($loop);
$pull = $context->getSocket(ZMQ::SOCKET_PULL);
$pull->bind('tcp://127.0.0.1:8090');
$pull->on('message', array($pusher, 'onEvent'));
$socket = new Server($url, $loop);
$webServer = new IoServer(
new HttpServer(
new WsServer(
new WampServer(
$pusher
)
)
),
$socket
);
echo ('Socket server runing at: ' . $socket->getAddress());
$loop->run();
I'm wondering if this issue as anything to do with nginx config or comes intrinsict related with my WebSocket server configuration.
If you use the WampServer it expects that the client will be talking the WAMPv1 protocol. The current versions of the autobahn library no longer support WAMPv1. For WAMPv1 you need to use autobahn 0.8.
Also, if you try to connect with plain websockets it will fail because of the missing subprotocol support.
If you need WAMPv2 support you can find that here: https://github.com/voryx/Thruway
I created my event loop via voryx/Thruway's router, but the error message persist.
@lautarolubatti Could you post your current code?
@mbonneau Hey Matt, i figured out that i was testing the connection via raw websocket, and that fails. Now i'm using Thruway js as client and works like a charm! Thanks!
I have a doubt, how can I connect a mobile app if this is the case? Im getting 426 when implementing Wamp, and is working ok when not implemented.
@marianoarga I am closing this issue because it is very old. Please let me know if you are still having issues.
Most helpful comment
If you use the
WampServerit expects that the client will be talking the WAMPv1 protocol. The current versions of the autobahn library no longer support WAMPv1. For WAMPv1 you need to use autobahn 0.8.Also, if you try to connect with plain websockets it will fail because of the missing subprotocol support.
If you need WAMPv2 support you can find that here: https://github.com/voryx/Thruway