New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Manual disconnect and reconnect to same URL #6510
Comments
@moehlone I was just about to ask this same question. In my case I want to unsubscribe from all models on log out, so I was hoping to just disconnect then reconnect the sails.io client. I got it to disconnect using |
I'm having the same issue as well. |
@eulercodex I used location.reload to accomplish this. If you are doing a SPA and don't want the flicker of a refresh, pass |
@mattblang I don't particularly use sails. The issue was with socket.io but after looking at the doc online 1.2 release note, I was able to solve my problem this way // on initialization
socket = io.connect({forceNew: true});
// for disconnection
socket.io.disconnect();
// for reconnection
socket = io.connect({forceNew: true}); |
io.connect({forceNew: true}); works just fine |
if you are using sails you need to edit sails.io.js SailsSocket function: function SailsSocket (opts){
var self = this;
opts = opts||{};
// Absorb opts
self.useCORSRouteToGetCookie = opts.useCORSRouteToGetCookie;
self.url = opts.url;
self.multiplex = opts.multiplex;
self.transports = opts.transports;
// Absorb forceNew opts to force a new websocket connection every time
self.forceNew = opts.forceNew;
.
.
. |
@ghost @eulercodex I had the similar problem here, and seems this |
Thanks for posting, @moehlone. I'm a repo bot-- nice to meet you! It has been 30 days since there have been any updates or new comments on this page. If this issue has been resolved, feel free to disregard the rest of this message. On the other hand, if you are still waiting on a patch, please:
Thanks so much for your help! |
The following way for power saving or reducing network traffic works fine in my case for platform browser or android. Also, it is not necessary to redefine the event handler for 'connect' setup in app config.
|
I want to disconnect manually from a socket and to a later time make a new connection to the same URL. At the moment it is not possible with sails.js - reconnection always fails.
Is there any possibility to solve this with sails.io.js?
See: socketio/socket.io-client#251
socket.io implemented in 1.0 a param called 'forceNew' for io.connect()
Best regards,
Phil
The text was updated successfully, but these errors were encountered: