[英]Ruby wamp-client gem - connection to crossbar.io
我是Ruby的新手
我正在嘗試使用wamp-client gem建立與crossbar.io路由器的連接。 Crossbar具有通過crossbar模板(python作為后端)創建的所有默認設置和應用程序。 當我通過瀏覽器連接時,一切都很好,但是當我嘗試通過簡單地使用ruby時
require "wamp/client"
wamp_test = WAMP::Client.new("ws://127.0.0.1:8080")
wamp_test.open
我有一個“ handle_opening_handshake_response”:未處理的打開握手響應#(Net :: WS :: Error)'錯誤。 我知道要處理握手,我的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
使用默認的(生成的)Crossbar.io配置時,請嘗試: ws://127.0.0.1:8080/ws
而不是ws://127.0.0.1:8080
。 WAMP-WebSocket傳輸位於子路徑上。
您可以通過在瀏覽器中打開http://127.0.0.1:8080
和http://127.0.0.1:8080/ws
進行檢查。
另外:您的客戶端不會發送有效的WebSocket子協議列表( Sec-Websocket-Protocol
為空)。 Crossbar.io有一個配置選項可以使該設置可接受(並假定為wamp.2.json
),但是更好的行為是在WebSocket客戶端庫中激活WebSocket子協議協商。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.