socket.io icon indicating copy to clipboard operation
socket.io copied to clipboard

How to 'restart' sockets immediately?

Open smitty260 opened this issue 12 years ago • 2 comments

Hello everyone.

I have an issue that I have been scratching my head over for a couple of days now. I am making an application using the Twitter Streaming API so it constantly streams tweets according to the user's input. Once the user changes the input I want it to update the Twitter feed immediately. I can easily update the search terms on the API but when I do that the feed keeps showing the tweets from the previous search terms and I think it may be caused by my socket.io connection. So I want to be able to cut off the connection to all the sockets and restart them again immediately or something similar to achieve what I want to happen. Just want to know how to do this or some ideas of how to do this?

My socket.io connection is initialised like so: var express = require('express'); var app = express(); var http = require('http').Server(app); var io = require('socket.io')(http);

Any suggestions or ideas are appreciated. If you want some more of my code for explanation or need me to expand on what I require then please let me know and I will do so.

Thank you.

smitty260 avatar Oct 23 '14 00:10 smitty260

You can use disconnect method on the socket and the connect again

ggrav avatar Oct 24 '14 14:10 ggrav

What @ggrav suggested should work.

rase- avatar Jan 12 '15 02:01 rase-