【发布时间】:2015-01-28 14:44:27
【问题描述】:
我正在尝试使用 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.
@ Unexpected response code: 426 with PhanthomJS Websocket client/ROSLIB
嗯,我的 VPS 是在一个 ngnix 反向代理后面。我无法访问它。所以这就是我使用 wss 的原因。
有人可以帮忙吗?
谢谢!
【问题讨论】:
标签: node.js proxy websocket primus