首页 > 解决方案 > 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"

如何解决问题?

标签: node.jsvue.jssocket.ionginx-reverse-proxy

解决方案


您需要在套接字连接中指定 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);

推荐阅读