node.js - sockjs-node net::ERR_CONNECTION_REFUSED
问题描述
我用 vue cli 创建了一个全新的微型 webapp,所以除了空的 vue-cli 脚手架带来的东西之外,没有添加任何东西:
(base) marco@pc:~/vueMatters/testproject$ npm run serve
> testproject@0.1.0 serve /home/marco/vueMatters/testproject
> vue-cli-service serve
INFO Starting development server...
98% after emitting CopyPlugin
DONE Compiled successfully in 1409ms 8:14:46 PM
App running at:
- Local: localhost:8080
- Network: 192.168.1.7:8080
Note that the development build is not optimized.
To create a production build, run npm run build.
并收到此错误消息:
GET https://localhost/sockjs-node/info?t=1580228998416 net::ERR_CONNECTION_REFUSED
节点--版本 v12.10.0
npm -v 6.13.6
webpack-cli@3.3.10
Ubuntu 18.04.03 服务器版
/var/log/nginx/error.log 的最后几行:
2020/01/28 18:10:57 [error] 980#980: *34 connect() failed (111:
Connection refused) while connecting to upstream, client:
66.249.79.119, server: ggc.world, request: "GET /robots.txt HTTP/1.1",
upstream: "http://127.0.0.1:8080/robots.txt", host: "ggc.world"
2020/01/28 18:11:37 [error] 980#980: *36 connect() failed (111:
Connection refused) while connecting to upstream, client: 66.249.79.70,
server: ggc.world, request: "GET /robots.txt HTTP/1.1", upstream:
"http://127.0.0.1:8080/robots.txt", host: "www.ggc.world"
如何解决问题?
解决方案
您需要在套接字连接中指定 SSL 证书。
这是参考。
var options = {
key: fs.readFileSync('./file.pem'),
cert: fs.readFileSync('./file.crt')
};
var server = https.createServer(options, app);
var io = require('socket.io')(server);
推荐阅读
- html - Flexbox css:如何将 2 个图像居中 - 顶部/底部
- python - SystemError:新样式 getargs 格式,但参数不是元组,Python 2.7-OpenCV
- c++ - 文本更改时的 QListWidget 可编辑项信号
- c# - 如何在 c# 中使用字典逐行读取输入数据(.json 文件)-> 通用代码
- php - 无法在 Laravel 5.7 中查看不同的文件类型
- macos - 激活选择元素 Safari - AppleScript
- php - 未捕获的 TypeError:来自请求方法的 PHP
- powerbi - 前 N 个错误百分比的 Power BI 总计
- php - PHP自动选择时间段
- android - 片段保存以前的状态,但不能正确恢复