I'm new in Ruby
I'm trying to use wamp-client gem to establish connection to crossbar.io router. Crossbar have all defaults settings and application created via crossbar template (python as back-end). When I'm connecting via browser everything is fine but when I'm trying to use ruby by simply
require "wamp/client"
wamp_test = WAMP::Client.new("ws://127.0.0.1:8080")
wamp_test.open
I have a `handle_opening_handshake_response': Unhandled opening handshake response # (Net::WS::Error)' error. I know that to handle handshake my WAMP router should send HTTP 101 switch protocol but it doesn't do that (can't see it in wireshark). Please help me out.
Client request:
GET / HTTP/1.1\r\n
Upgrade: websocket\r\n
Connection: Upgrade\r\n
Sec-Websocket-Key: RggxGCwmcnVuEB08UQMCWA==\r\n
Sec-Websocket-Version: 13\r\n
Sec-Websocket-Protocol: \r\n
Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\n
Accept: */*\r\n
User-Agent: Ruby\r\n
Host: localhost:8080\r\n
\r\n
Full request URI: http://localhost:8080/
HTTP request 1/1
Router return:
HTTP/1.1 200 OK\r\n
Server: Crossbar/0.11.1\r\n
Date: Mon, 01 Feb 2016 07:48:33 GMT\r\n
Cache-Control: max-age=43200, public\r\n
Expires: Mon, 01 Feb 2016 19:48:33 GMT\r\n
Accept-Ranges: bytes\r\n
Content-Length: 5085\r\n
Content-Type: text/html\r\n
Last-Modified: Thu, 28 Jan 2016 13:07:24 GMT\r\n
\r\n
HTTP response 1/1
Line-based text data: text/html
When using the default (generated) Crossbar.io configuration, try:
ws://127.0.0.1:8080/ws
instead ofws://127.0.0.1:8080
. The WAMP-WebSocket transport is on a subpath.You can check by opening
http://127.0.0.1:8080
andhttp://127.0.0.1:8080/ws
in your browser.Also: your client does not send a valid WebSocket subprotocol list (
Sec-Websocket-Protocol
is empty). Crossbar.io has a config option to make that acceptable (and the assumewamp.2.json
), but a better behavior would be to activate WebSocket subprotocol negotiation in your WebSocket client library.