无法连接到wss://(连接建立错误:net :: ERR_CONNECTION_CLOSED)

戴夫(L. Dave)

我的LPS有VPS。我有来自Startssl.com的免费签名SSL证书(ssl证书正常工作)

使用http://协议,我可以连接到,ws://chat.example.com:1337/some-variable但是当我替换协议时http://https://则无法连接到wss://chat.example.com:1337/some-variable

当我尝试连接时wss://出现错误Error in connection establishment: net::ERR_CONNECTION_CLOSED

为什么?

// http://ejohn.org/blog/ecmascript-5-strict-mode-json-and-more/
"use strict";

// Optional. You will see this name in eg. 'ps' or 'top' command
process.title = 'node-chat';

// Port where we'll run the websocket server
var webSocketsServerPort = 1337;

// websocket and http servers
var webSocketServer = require('websocket').server;
var http = require('http');
var $ = require("jquery");

    /**
     * HTTP server
     */
var server = http.createServer(function(request, response) {
    // Not important for us. We're writing WebSocket server, not HTTP server

});
server.listen(webSocketsServerPort, function() {
    console.log((new Date()) + " Server is listening on port " + webSocketsServerPort);
});

/**
 * WebSocket server
 */
var wsServer = new webSocketServer({
    // WebSocket server is tied to a HTTP server. WebSocket request is just
    // an enhanced HTTP request. For more info http://tools.ietf.org/html/rfc6455#page-6
    httpServer: server
});

编辑

我有来自http://ahoj.io/nodejs-and-websocket-simple-chat-tutorial的源代码

乔尼·Whatshisface

为了更好地批评我的答案,因为最后一个是一个错误,并且我不打算在完成挖掘后才提交它,请尝试以下操作:

    // Private key and certification
    var options = {
      key: fs.readFileSync('cert/server.key'),
      cert: fs.readFileSync('cert/server.crt')
    };


    var server = https.createServer(options, function(request, response) {
    console.log((new Date()) + ' Received HTTP(S) request for ' +     request.url);
    }

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

WebSocket连接建立错误:net :: ERR_CONNECTION_CLOSED

来自分类Dev

net::ERR_CONNECTION_CLOSED 在 Angular 2 Firebase 应用中

来自分类Dev

无法访问此站点 (ERR_CONNECTION_CLOSED) javascript 检测 window.open

来自分类Dev

无法连接到localhost中的wordpress(GET http:// localhost / net :: ERR_CONNECTION_REFUSED)

来自分类Dev

Node.js服务器+ SSL = ERR_CONNECTION_CLOSED

来自分类Dev

导轨电缆连接建立错误:net :: ERR_SSL_PROTOCOL_ERROR

来自分类Dev

nginx ssl_certificate指令在服务器块中不起作用,浏览器显示ERR_CONNECTION_CLOSED或ERR_CONNECTION_RESET

来自分类Dev

nginx ssl_certificate指令在服务器块中不起作用,浏览器显示ERR_CONNECTION_CLOSED或ERR_CONNECTION_RESET

来自分类Dev

连接到ProFTPD时出现FileZilla错误:“无法建立数据连接:ETIMEDOUT-连接尝试超时”

来自分类Dev

与gen_tcp并行建立大量连接时出现CLOSED错误(错误?)

来自分类Dev

XSockets WSS无法连接

来自分类Dev

连接到 SQL Server for PHP:无法建立连接

来自分类Dev

通过外部IP连接到我的RaspberryPi时出现ERR_CONNECTION_RESET

来自分类Dev

无法建立数据库连接 -dberror(Connection.prepareStatement): 258 - 权限不足:未授权

来自分类Dev

ASP.NET MVC 错误 50 无法连接到 localDB

来自分类Dev

Wget返回错误:“无法建立SSL连接。”

来自分类Dev

错误:无法与R会话建立连接

来自分类Dev

使用 OrientJS 模块连接到 NodeJS 中的 OrientDB -- “Socket Closed” 错误

来自分类Dev

无法连接到FTP服务器:425无法建立数据连接:连接超时

来自分类Dev

Websocket连接失败,是否可以捕获“无法建立连接”错误?

来自分类Dev

mongoengine.connection.ConnectionError:无法连接到数据库默认值:[Errno 111]连接被拒绝

来自分类Dev

Node.js + Express-无法连接。ERR_CONNECTION_REFUSED

来自分类Dev

LTE连接上的Chrome err_connection_reset

来自分类Dev

ActiveRecord::Base.establish_connection 连接到错误的数据库

来自分类Dev

无法建立JDBC连接

来自分类Dev

无法连接到数据库(HY000 / 1045),尝试使用php mysqli_connection连接到数据库

来自分类Dev

无法连接到MongoLab“验证失败”错误

来自分类Dev

错误:无法连接到[undefined:27017]

来自分类Dev

Freepbx无法连接到星号错误的密码

Related 相关文章

  1. 1

    WebSocket连接建立错误:net :: ERR_CONNECTION_CLOSED

  2. 2

    net::ERR_CONNECTION_CLOSED 在 Angular 2 Firebase 应用中

  3. 3

    无法访问此站点 (ERR_CONNECTION_CLOSED) javascript 检测 window.open

  4. 4

    无法连接到localhost中的wordpress(GET http:// localhost / net :: ERR_CONNECTION_REFUSED)

  5. 5

    Node.js服务器+ SSL = ERR_CONNECTION_CLOSED

  6. 6

    导轨电缆连接建立错误:net :: ERR_SSL_PROTOCOL_ERROR

  7. 7

    nginx ssl_certificate指令在服务器块中不起作用,浏览器显示ERR_CONNECTION_CLOSED或ERR_CONNECTION_RESET

  8. 8

    nginx ssl_certificate指令在服务器块中不起作用,浏览器显示ERR_CONNECTION_CLOSED或ERR_CONNECTION_RESET

  9. 9

    连接到ProFTPD时出现FileZilla错误:“无法建立数据连接:ETIMEDOUT-连接尝试超时”

  10. 10

    与gen_tcp并行建立大量连接时出现CLOSED错误(错误?)

  11. 11

    XSockets WSS无法连接

  12. 12

    连接到 SQL Server for PHP:无法建立连接

  13. 13

    通过外部IP连接到我的RaspberryPi时出现ERR_CONNECTION_RESET

  14. 14

    无法建立数据库连接 -dberror(Connection.prepareStatement): 258 - 权限不足:未授权

  15. 15

    ASP.NET MVC 错误 50 无法连接到 localDB

  16. 16

    Wget返回错误:“无法建立SSL连接。”

  17. 17

    错误:无法与R会话建立连接

  18. 18

    使用 OrientJS 模块连接到 NodeJS 中的 OrientDB -- “Socket Closed” 错误

  19. 19

    无法连接到FTP服务器:425无法建立数据连接:连接超时

  20. 20

    Websocket连接失败,是否可以捕获“无法建立连接”错误?

  21. 21

    mongoengine.connection.ConnectionError:无法连接到数据库默认值:[Errno 111]连接被拒绝

  22. 22

    Node.js + Express-无法连接。ERR_CONNECTION_REFUSED

  23. 23

    LTE连接上的Chrome err_connection_reset

  24. 24

    ActiveRecord::Base.establish_connection 连接到错误的数据库

  25. 25

    无法建立JDBC连接

  26. 26

    无法连接到数据库(HY000 / 1045),尝试使用php mysqli_connection连接到数据库

  27. 27

    无法连接到MongoLab“验证失败”错误

  28. 28

    错误:无法连接到[undefined:27017]

  29. 29

    Freepbx无法连接到星号错误的密码

热门标签

归档