2014-11-30 1 views
0

취소 :NodeJS와 Primus.io 웹 소켓 개방 핸드 셰이크 내가 프리머스 사용 ​​WebSocket을 연결하기 위해 노력하고있어

WebSocket connection to 'wss://dev.dylaan.nl/primus/?_primuscb=1417355606238-6' failed: WebSocket opening handshake was canceled

내 NodeJS 스크립트 :

var express  = require("express") 
, fs   = require("fs") 
, path  = require("path") 
, moment  = require("moment") 
, Primus  = require("primus") 
, compression = require("compression") 
, app   = express() 
, http  = require("http").createServer(app) 
, jsp   = require("uglify-js").parser 
, pro   = require("uglify-js").uglify 
, primus  = new Primus(http, { transformer: "websockets" }); 

클라이언트 :

var primus  = new Primus("wss://dev.dylaan.nl") 

저는 이런 종류의 물건에 익숙하지 않지만, 지금 무엇이 잘못 됐는지를 모릅니다. 프리 머스 (Primus)의 문서를 읽었을 때, 나는 또한 구글을 시도했지만 대답을 찾을 수있다. 내가 ws 대신 wss의에 프로토콜 변경하면

나는 오류를

Error during WebSocket handshake: Unexpected response code: 426

http 426 may mean that you are trying to connect with an unsupported websocket protocol version

Also, if you are connecting through a proxy, the proxy may remove the "upgrade" header from the request since it is marked as "connection" header. Switch to WSS:// to prevent that.

Unexpected response code: 426 with PhanthomJS Websocket client/ROSLIB

음 @, 내 VPS를 얻을 수 ngnix 역방향 프록시 뒤에 있습니다. 나는 그것에 접근 할 수 없다. 그래서 내가 왜 wss를 사용하고 있는지.

데모 : http://dev.dylaan.nl/play

누군가가 도와 드릴까요?

감사합니다.

답변

0

nginx 서버를 잘못 구성했으며 WebSocket 연결이 차단되어 400 오류가 반환되는 것으로 보입니다. 웹 소켓 연결을 허용하도록 서버를 구성하는 방법은 http://nginx.com/blog/websocket-nginx/을 참조하십시오. 클라이언트 코드에서 옵션 { websocket: false }을 제공하여 웹 소켓 커넥트는 프리머스에서 완전히 WebSocket을 해제 할 수 있습니다 허용되는 것을 확인하기 위해 호스트/VPS를 얻을 수없는 경우

는 :

new Primus("http://dev.dylaan.nl", { websocket: false }) 

나는 또한 당신이 wss/ws을 사용주의 Primus가 필요로하는 http 대신에 HTTP 기반 URL을 올바른 형식으로 자동으로 다시 작성합니다.

+0

저는 Primus 버전 2.4.10을 사용 중이며 클라이언트 라이브러리는 ws : // urls를 허용합니다. – op1ekun