2016-02-01 75 views
0

我是新的紅寶石紅寶石wamp-客戶端寶石 - 連接到crossbar.io

我想用wamp-client gem建立連接到crossbar.io路由器。交叉開關具有通過交叉開關模板創建的所有默認設置和應用程序(python作爲後端)。當我通過瀏覽器連接一切是好的,但是當我試圖通過簡單地

require "wamp/client" 
wamp_test = WAMP::Client.new("ws://127.0.0.1:8080") 
wamp_test.open 

使用Ruby我有一個`handle_opening_handshake_response「:未處理的開放握手迴應#(淨:: WS ::錯誤)」錯誤。 我知道要處理握手我的WAMP路由器應發送HTTP 101交換機協議,但它不這樣做(無法在wireshark中看到它)。 請幫我一把。

客戶端請求:

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 

路由器返回:

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 

回答

0

當使用缺省(生成)Crossbar.io配置,嘗試:ws://127.0.0.1:8080/ws代替ws://127.0.0.1:8080。 WAMP-WebSocket傳輸位於子路徑上。

您可以通過在您的瀏覽器中打開http://127.0.0.1:8080http://127.0.0.1:8080/ws進行檢查。

此外:您的客戶端不會發送有效的WebSocket子協議列表(Sec-Websocket-Protocol爲空)。 Crossbar.io有一個配置選項來使其可以接受(並且假設wamp.2.json),但更好的行爲是在WebSocket客戶端庫中激活WebSocket子協議協商。

+0

我已經添加了wamp_test = WAMP :: Client.new(「ws://127.0.0.1:8080/ws」,::subprotocols => [「wamp.2.json」]),現在Sec-Websocket-協議是wamp.2.json,但仍然沒有連接 - 同樣的錯誤。這個紅寶石是舊的,所以我不確定它是否支持WAMPv2 –

+0

看看快速谷歌搜索可以找到的兩個Ruby的WAMP實現,根據他們的年齡,他們都不支持WAMP v2。 – gzost