Answer the question
In order to leave comments, you need to log in
socket.io reopens connection every 50 seconds what's the problem?
Socket.io-client seems to stop transmitting data. Is there an internal reason for this?
Every 50 seconds, it reopens the connection.
I have a simple Node js socket.io server. And a React client. They work on different ports. Could this be the problem?
Function code, it opens once in componentDidMount()
import io from "socket.io-client";
import { isAuthenticated} from "../Api/Auth"
const jwt = isAuthenticated().token
export const testSoket = () => {
const socket = io.connect('http://localhost:4001', { query: {
token: jwt
}
});
socket.on("news")
}
Answer the question
In order to leave comments, you need to log in
did it like this. And it does not reconnect, surprisingly. I don't know why, but it works as it should.
import io from "socket.io-client";
import { isAuthenticated} from "../Api/Auth"
const jwt = isAuthenticated().token
const socket = io.connect('http://localhost:4001',
{ query: {token: jwt}
})
export const testSoket = () => {
socket.on("news")
socket.on('disconnect', function(){});
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question