我无法成功设置套接字连接。调试时出现以下错误
socket error {"type":"TransportError","description":{"target":{"_events":{},"_eventsCount":4,"readyState":2,"protocol":"","_binaryType":"arraybuffer","_closeFrameReceived":false,"_closeFrameSent":false,"_closeMessage":"","_closeTimer":null,"_closeCode":1006,"_extensions":{},"_isServer":false,"_receiver":null,"_sender":null,"_socket":null,"url":"ws://IP:PORT/socket.io/?EIO=3&transport=websocket","_req":null},"type":"error","message":"Parse Error","error":{"bytesParsed":0,"code":"HPE_INVALID_CONSTANT"}}}
代码
let io = require('socket.io-client');
const socketClient = io.connect(listenTo,{ transports: ['websocket'],reconnect: true,secure:true,rejectUnauthorized: false});
console.log('inited it');
console.log(socketClient)
socketClient.on('connection',function(socketClient){
console.log('connection setup'+socketClient.connected)
})
我添加了选项传输:['websocket']来修复错误
ngine.io-client:套接字套接字错误 {“ type”:“ TransportError”,“ description”:503}
任何提示可能有什么问题