Search code examples
node.jstwitternpmbots

Node.js Twitter Bot returning Error: Bad Twitter streaming request: 410


I ran the bot and it ran for about 8 hours but now it's giving the following issue as soon as I run it:

events.js:183
  throw er; // Unhandled 'error' event
  ^Error: Bad Twitter streaming request: 410
at Object.exports.makeTwitError (C:\Users\arghya\Documents\Node-JS\Gracias\node_modules\twit\lib\helpers.js:74:13)
at Request.<anonymous> (C:\Users\arghya\Documents\Node-JS\Gracias\node_modules\twit\lib\streaming-api-connection.js:96:29)
at emitOne (events.js:121:20)
at Request.emit (events.js:211:7)
at IncomingMessage.<anonymous> (C:\Users\arghya\Documents\Node-JS\Gracias\node_modules\request\request.js:1083:12)
at Object.onceWrapper (events.js:313:30)
at emitNone (events.js:111:20)
at IncomingMessage.emit (events.js:208:7)
at endReadableNT (_stream_readable.js:1064:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)

You can refer the code here.

Edit: The same code started working after a few hours. I guess it's a timeout issue from the API.


Solution

  • The API you are using via var stream = twitter.stream('user'); in your code refers to the deprecated user streams endpoint.

    This is due to be completely removed on August 23rd, but ahead of that date, the endpoints are being periodically switched off to remind developers that they need to migrate to an alternative method such as the Account Activity API. You can read more about the schedule for this downtime here. That's why you are seeing the temporary 410 error. It will become increasingly frequent over this week.