SpiderStrategies / node-tweet-stream

Node twitter module to hook into the public filter streaming, seamlessly updating the tracking keywords.
210 stars 43 forks source link

Error: Uncaught, unspecified "error" event #44

Closed cwarny closed 8 years ago

cwarny commented 8 years ago

Upgraded to 2.0 and getting this error as soon as I try to connect to the Twitter stream. With same credentials, same code, when I downgrade to 1.10.0, it works fine. This happens on this.emit( "error") line

nathanbowser commented 8 years ago

@robturtle Did you see this? https://github.com/SpiderStrategies/node-tweet-stream/pull/40

robturtle commented 8 years ago

@cwarny Could you please add one line yourTwitterStreamInstance.on('error', function (err) { console.log(err) }) to check what specific error it is?

cwarny commented 8 years ago
{ type: 'http',
  err: [Error: Twitter connection error 406],
  explain: 
   { type: 'not-acceptable',
     long: 'At least one request parameter is invalid.' } }

Note that I use the exact same credentials as in 1.10.0, and it works fine in the latter.

robturtle commented 8 years ago

Can you provide the parameters you passed to the tracking function. Since the change from 1.10.0 to 2.0.0 doesn't change the logic of parameter handling, my current guess is maybe some of your parameters are invalid in the code but the old version just emit 'reconnect' silently. Give me your passing parameters so I can verify this. You can also check for yourself by printing out all statusCode of responses.

cwarny commented 8 years ago

Well, not sure it's appropriate to share my Twitter credentials... It's just an object with the following keys:

{
    consumer_key: process.env.TWITTER_CONSUMER_KEY_DEV,
    consumer_secret: process.env.TWITTER_CONSUMER_SECRET_DEV,
    token: process.env.TWITTER_TOKEN_DEV,
    token_secret: process.env.TWITTER_TOKEN_SECRET_DEV
}
cwarny commented 8 years ago

I think I found the problem. My bad. I was setting the language of my twitter stream instance without specifying a track. Feel free to close this.

nathanbowser commented 8 years ago

@cwarny Cool. Thanks for the update.

robturtle commented 8 years ago

@cwarny By saying parameters I didn't mean the credentials but the parameters passed to the twitter API. This reminds me that maybe the explanations can be more specific than current, and adding a default 'error' handler may reduce the confusions. I will create a PR for that later.