Code Monkey home page Code Monkey logo

Comments (8)

fent avatar fent commented on August 19, 2024

From line 251 on lib/twitter.js it looks like trying to open a twitter stream gives an HTTP error.

Also unrelated but if all of the streams you open will track the same thing regardless of user connecting, just open one stream and broadcast to all users from that.

from ntwitter.

gabrielstuff avatar gabrielstuff commented on August 19, 2024

Also unrelated but if all of the streams you open will track the same thing regardless of user connecting, just open one stream and broadcast to all users from that.

Hey, you are totally right, actually I would much prefere to push the unique stream to all user any time the twitter stream got something.

About lib/twitter.js causing the error, what should I do ?

from ntwitter.

fent avatar fent commented on August 19, 2024

Always listen to the error event from streams, and from event emitters that might emit it. In this case, listen to it, read what it says. It's probably something with your credentials.

If not, might have something to do with twitter recently updating their API to v1.1, in which case the URLs this module uses would need to be updated.

from ntwitter.

gabrielstuff avatar gabrielstuff commented on August 19, 2024

Well, the app is working sometime, and sometime not.
To me (from the C++ world) it looks like memory error or stuff like that.
Credential are fine, as I frequently get all the tweet I want.

When you say you want me to listen to error, do you mind that it is mandatory ? if so, why all the example does not show it ? or am I missing something ?

Thank you,

from ntwitter.

fent avatar fent commented on August 19, 2024

The error is being emitted from when ntwitter tries to open the stream. My guess would be that it's working sometimes because the first few streams you open connect without problems and after a while you'll get rate limited since you never close the previous streams.

I'm also not positive but I think socket.io should give an error if you try to socket.emit() on a closed connection.

It's not in the examples because the node API for event emitters already say that you should always listen for possible error events, else they will be thrown.

from ntwitter.

gabrielstuff avatar gabrielstuff commented on August 19, 2024

looks pretty straightforward. Going to add the error handling part, which means I have to add it for socket.io AND twitter, right ?

Also, would you mind guide me about streaming the twitter data from one stream and broadcast that to user instead of opening the stream each time I got a connection.

Thank,

from ntwitter.

fent avatar fent commented on August 19, 2024

I'm not sure socket.io emits any error events. It usually just emits when users connect/disconnect. It might emit errors although I've never encountered one.

Which is a bit inconsistent to what I just said. Just read the API on the modules, they should say if they emit error events.

to emit to all socket.io connected users

t.stream(
    'statuses/filter',
    { track: ['awesome', 'cool', 'rad', 'gnarly', 'groovy'] },
    function(stream) {
        stream.on('data', function(tweet) {
            //console.log(tweet.text);
            new_tweet = tweet.text;
            io.sockets.emit('new_tweet', new_tweet);
        });
    }
);

from ntwitter.

gabrielstuff avatar gabrielstuff commented on August 19, 2024

Well, after reading and learning, I say lets close that issue :)

Thank for your grateful help !

from ntwitter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.