【问题标题】:Socket.IO with Express will not connect using https (Apache2 Ubuntu16.04)带有 Express 的 Socket.IO 将无法使用 https 连接(Apache2 Ubuntu16.04)
【发布时间】:2017-06-26 17:54:18
【问题描述】:

我对 SSL 证书不是很有经验,我希望有人可以帮助我找出我做错了什么。

我正在尝试使用自己的端口 (*:1729) 托管 NodeJS 应用程序,Apache2 在端口 443 上启用了 SSL(它从该端口为客户端应用程序提供服务,而不是相关的 NodeJS/Express/Socket.io 应用程序)。当我使用 http 设置 Express 时,它可以正常工作,我的客户端应用程序与 NodeJS 应用程序通信时不会出错,但是当我将 https 与 express 一起使用时,如下所示:

this.express = require('express');  
this.app = this.express();

var https = require('https');  
var fs = require('fs');

var sslPath = '/etc/letsencrypt/live/yourdomain.example.com/';

var options = {  
    key: fs.readFileSync(sslPath + 'privkey.pem'),
    cert: fs.readFileSync(sslPath + 'fullchain.pem')
};

this.server = https.createServer(options, this.app);  
this.io = require('socket.io').listen(this.server);  
this.server.listen(1729);  

当我的客户端应用程序尝试连接时,我会收到此错误:

node: ../src/util-inl.h:196: TypeName* node::Unwrap(v8::Local<v8::Object>) [with TypeName = node::TLSWrap]: Assertion ``(object->InternalFieldCount()) > (0)' failed. Aborted (core dumped)

任何可以为我指明正确方向的建议或更正将不胜感激,谢谢!

【问题讨论】:

  • 您使用的是哪个版本的 Node.js? node --version
  • 我正在使用节点 v4.2.6

标签: node.js https socket.io


【解决方案1】:

感谢您的帮助! :) 将我的 NodeJS 更新到最新版本使错误消失并且应用程序与客户端通信也没有错误。

node: Github issue # 3682

我只是按照这些步骤操作。

AskUbuntu: How can I update my nodeJS to the latest version?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-03-05
    • 1970-01-01
    • 2014-08-05
    • 2018-05-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多