Initial connection timeout or reconnect when namespace is not yet created #4243
Unanswered
andredewaard
asked this question in
Q&A
Replies: 1 comment
-
Hi! I'm not sure to totally understand your use case, but you should be able to use the import { io } from "socket.io-client";
const socket = io({
autoConnect: false
});
// and then later
socket.connect();
// or after a given delay
setTimeout(() => {
socket.connect();
}, 5000); Reference: https://socket.io/docs/v4/client-options/#autoconnect |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Is it possible to open a connection only after a certain time?
So an initial connection timeout.
We create different namespaces for each 'object' inside the database. When something happens on a certain 'object' when broadcast an event on that specific namespace.
When we create an 'object' the namespace for this object is not created immediately so when trying to connect to the websocket the connection to the server is there only the namespace doesnt exist yet. SocketIO then throws an error instead of trying to reconnect.
Beta Was this translation helpful? Give feedback.
All reactions