2017-03-17 131 views
1

我正尝试使用socket.io第一次。 我使用Laravel 5.4,Laravel Echo和NodeJs server for Laravel Echo broadcasting with Socket.io.GET https://mydomain.server:6001/socket.io/socket.io.js net :: ERR_CONNECTION_REFUSED

我设法使它在本地工作,因为它应该工作。但在服务器上我得到 错误

GET https://mydomain.server:6001/socket.io/socket.io.js net::ERR_CONNECTION_REFUSED 

我做之前运行的服务器。我写了正确的地址。 enter image description here

可能是浏览器无法访问该端口或什么?

另外我试图用 curl -X GET https://mydomain.server:6001/socket.io/socket.io.js命令访问文件。

但是得到了 curl: (35) gnutls_handshake() failed: The TLS connection was non-properly terminated

+0

我也面临着我的服务器上同样的问题。但它与https无关。我的域名有http协议。你能告诉我错误的可能性吗? –

回答

0

我找到了解决方案。在laravel回波-server.json

"protocol": "https", 
"sslCertPath": "path_to/server.crt", 
"sslKeyPath": "path_to/server.key" 
0

只需设置协议,sslCertPath和sslKeyPath参数可能是这将帮助你。 首先,当你连接到插座,然后再安装SSL站点是有使用:

socket = io.connect('http://example.com:port', {'force new connection': true, 'secure': true}); 

包括上面的客户端脚本一部分一部分。

其次在服务器端在你的如:server.js说使用

var https = require('https'); 
var server = https.createServer({ 
    key : fs.readFileSync('./sslkey.key'), 
    cert : fs.readFileSync('./ssl_certificate.crt') 
},app); 
+0

如果我不使用Laravel Echo Server,它可以帮助我。但它肯定会给我一个想法,如何用Laravel Echo Server解决这个问题。如果您有兴趣,我已经找到了解决方案,请在下面查看我的答案。谢谢 –

相关问题