【问题标题】:sockjs-node net::ERR_CONNECTION_REFUSED [duplicate]sockjs-node net::ERR_CONNECTION_REFUSED [重复]
【发布时间】:2023-03-23 18:56:01
【问题描述】:

我用 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.js vue.js socket.io nginx-reverse-proxy


    【解决方案1】:

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

    【讨论】:

    • 我应该在我的套接字连接中具体在哪里指定 SSL 证书?
    • 你能在这里发布一些参考资料来解释如何做吗?
    • 我已经更新了答案
    • 我会把这个放在哪里?
    • @MaxCoplan 您在谈论密钥和证书文件吗?
    猜你喜欢
    • 2018-01-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-17
    相关资源
    最近更新 更多