Skip to content
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

Server crashes if no tweets #1

Open
alexismo opened this issue Oct 2, 2012 · 3 comments
Open

Server crashes if no tweets #1

alexismo opened this issue Oct 2, 2012 · 3 comments

Comments

@alexismo
Copy link

alexismo commented Oct 2, 2012

I'm doing a project and pooling for a nonexisting hashtag. Your server code crashes 1 minute after the 1st connection attempt if no tweet are available after the 1st minute.

Your server implementation doesn't take keepalives in consideration.
https://dev.twitter.com/docs/streaming-apis/connecting#Stalls

Will throw

events.js:45
        throw arguments[1]; // Unhandled 'error' event

and crash.

I'm in the process of writing something that catches keepalives but I'm brand new at node.js so I'm not ready to submit a pull request just yet.

@ralyodio
Copy link
Owner

ralyodio commented Oct 2, 2012

Can you give me an example search that you're using? I will try to reproduce. path: '/1/statuses/filter.json?locations=-122.75,36.8,-121.75,37.8',

@alexismo
Copy link
Author

alexismo commented Oct 2, 2012

I've been searching for path: /1/statuses/filter.json?track=some_random_hastag_no_one_will_ever_use.

The idea is that this search will not return anything and the browser will close the connection. I got a fix working earlier today. Maybe you can include that.

//stream.js [server side]
result.on('data', function(chunk){
                if(chunk == '\r\n'){//got a keepalive
                    res.write("event: keepalive\n");
                }else{
                    jsonTwitter.feed(chunk);
                }
            });

//main.js [client side]
source.addEventListener('keepalive', function(e){
        //you don't actually have to do anything with this.
        console.log("keepalive received");
    });

@ralyodio
Copy link
Owner

Thanks. I will add this fix soon. I am thinking about revamping the entire app to use express.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants