![](/img/trans.png)
[英]PHP Websocket ERROR: net::ERR_SSL_PROTOCOL_ERROR using cloudflare
[英]Error in connection establishment: net::ERR_SSL_PROTOCOL_ERROR is thrown when trying establish and connect to a websocket server
如標題所示,建立和連接服務器時出現錯誤。 我正在使用一個名為simple-websocket的npm庫來實現此目的。
在服務器端,我正在使用節點,而對於前端,我正在使用browserify捆綁節點模塊。 我已經嘗試過更改端口,並搜索了沒有結果的修復程序。
這是我的節點代碼:
const Server = require('simple-websocket/server')
const server = new Server({port: 8181})
new Promise((resolve, reject) => {
server.on('connection', function(socket, request) {
resolve({socket, request})
})
}).then(data => {
console.log(data)
})
這是我的網絡代碼:
const Socket = require('simple-websocket')
exports.test = function() {
const socket = new Socket('wss://localhost:8181')
socket.on('connect', function() {
console.log('yes')
})
}
這是完整的錯誤:
WebSocket connection to 'wss://localhost:8181/' failed: Error in connection
establishment: net::ERR_SSL_PROTOCOL_ERROR
bundle.js:6106 Uncaught Error: connection error to wss://localhost:8181
at WebSocket.Socket.self._ws.onerror (bundle.js:6106)
Socket.self._ws.onerror @ bundle.js:6106
error (async)
Socket @ bundle.js:6105
exports.test @ bundle.js:2841
9../middleware-comms/Listen @ bundle.js:2836
o @ bundle.js:1
r @ bundle.js:1
(anonymous) @ bundle.js:1
如果有用,請使用以下瀏覽器代碼: http : //www.filedropper.com/bundle_2
您創建的simple-websocket/server
實例不是在監聽加密的/ wss / ssl連接,而是在監聽標准的websocket連接。 您應該嘗試使用ws://localhost:8181
(而不是wss://...
)連接到它。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.