2017-03-17 133 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解決這個問題。如果您有興趣,我已經找到了解決方案,請在下面查看我的答案。謝謝 –

相關問題