-1
我試圖讓WebSockets的連接去,我不斷收到以下錯誤: WebSocket connection to 'ws://localhost:3000/socket.io/?EIO=3&transport=websocket&sid=w6H2vNXXbYIOhwPQAAAA' failed: Error during WebSocket handshake: Unexpected response code: 400
錯誤:400
我的代碼是非常簡單 - 在客戶端我打電話this.socket = io();
和在服務器端我正在做下面的事情。我已經注意到這個主題上的幾個相關的帖子,並嘗試了很多變化,但似乎沒有任何工作。感謝提前:)
const app = require("http").createServer(handler);
const io = require("socket.io")(app);
app.listen(3000);
class Sockets {
constructor() {
this.humanPlayers = [];
this.socket = io.listen(app);
this.setEventHandlers();
}
}