Answer the question
In order to leave comments, you need to log in
Socket.io why connects twice?
Good afternoon.
const io = require('socket.io-client')
const socket = io("http://localhost:1900", {
transports: ["websocket"]
})
io.sockets.on('connection', function (socket) {
console.log('hello: ' + socket.id)
})
Answer the question
In order to leave comments, you need to log in
Are you doing it in react or native js?
if react then wrap it in useEffect
function main(){
useEffect(()=>{
const socket = io("http://localhost:1900", {
transports: ["websocket"]
})
},[])
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question