In socket.io client option, what is the difference between 'reconnection
' and 'forceNew
'
socket("my-host-server", {
reconnection: true,
reconnectionDelay: 3000,
reconnectionAttempts: 20,
forceNew: true
});
reconnection
enables/disables automatic re-connection of the client ie if the server drops or clients internet connection drops it'll attempt re-connection
For socket.io(url[, options])
from https://socket.io/docs/client-api/
Creates a new Manager for the given URL, and attempts to reuse an existing Manager for subsequent calls, unless the multiplex option is passed with false. Passing this option is the equivalent of passing 'force new connection': true or forceNew: true.
So essentially if you don't specify forceNew: true
it'll attempt to reuse an available Manager
presumably one that's been disconnected. By the looks of things some people have run into trouble with manually disconnecting and reconnecting without specifying this option(socket.io client connect disconnect), however I'm not familiar enough with Sockets.io to be able to comment on other potential caveats of specifying this option.