我正在尝试使用 websockets 与 Primus 连接:
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.
@ 意外响应代码:426 with PhanthomJS Websocket client/ROSLIB
好吧,我的 VPS 在一个 ngnix 反向代理后面。我无权访问。所以这就是我使用 wss 的原因。
有人可以帮忙吗?
谢谢!