botgram / shell-bot

:robot: Telegram bot that executes commands and sends the live output
GNU General Public License v3.0
787 stars 493 forks source link

Random crash when the bot is not even in use #25

Open samthelion17 opened 4 years ago

samthelion17 commented 4 years ago

Hi, i'm seeing this messages in the terminal where i run shell-bot even though the bot is active but not in use. I always start the bot, go to telegram and issue the /status command to check that is working, and then time later, the bot stops working. This are the messages:

Error when updating: { NetworkError: getUpdates failed: Error: socket hang up
    at new NetworkError (/home/sysadmin/.telegrambots/shell-bot/node_modules/botgram/lib/bot.js:20:20)
    at ClientRequest.handleResponse (/home/sysadmin/.telegrambots/shell-bot/node_modules/botgram/lib/bot.js:133:24)
    at ClientRequest.callback (/home/sysadmin/.telegrambots/shell-bot/node_modules/form-data/lib/form_data.js:471:19)
    at emitOne (events.js:116:13)
    at ClientRequest.emit (events.js:211:7)
    at TLSSocket.socketOnEnd (_http_client.js:423:9)
    at emitNone (events.js:111:20)
    at TLSSocket.emit (events.js:208:7)
    at endReadableNT (_stream_readable.js:1064:12)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
When calling method getUpdates: { offset: 934597283, timeout: 600 }
    at Bot.callMethod (/home/sysadmin/.telegrambots/shell-bot/node_modules/botgram/lib/bot.js:102:18)
    at Bot.consumeUpdates (/home/sysadmin/.telegrambots/shell-bot/node_modules/botgram/lib/bot.js:201:8)
    at Bot.<anonymous> (/home/sysadmin/.telegrambots/shell-bot/node_modules/botgram/lib/bot.js:219:20)
    at handleBody (/home/sysadmin/.telegrambots/shell-bot/node_modules/botgram/lib/bot.js:157:25)
    at IncomingMessage.<anonymous> (/home/sysadmin/.telegrambots/shell-bot/node_modules/botgram/lib/bot.js:146:33)
    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)
  name: 'NetworkError',
  stack: 'NetworkError: getUpdates failed: Error: socket hang up\n    at new NetworkError (/home/sysadmin/.telegrambots/shell-bot/node_modules/botgram/lib/bot.js:20:20)\n    at ClientRequest.handleResponse (/home/sysadmin/.telegrambots/shell-bot/node_modules/botgram/lib/bot.js:133:24)\n    at ClientRequest.callback (/home/sysadmin/.telegrambots/shell-bot/node_modules/form-data/lib/form_data.js:471:19)\n    at emitOne (events.js:116:13)\n    at ClientRequest.emit (events.js:211:7)\n    at TLSSocket.socketOnEnd (_http_client.js:423:9)\n    at emitNone (events.js:111:20)\n    at TLSSocket.emit (events.js:208:7)\n    at endReadableNT (_stream_readable.js:1064:12)\n    at _combinedTickCallback (internal/process/next_tick.js:138:11)\nWhen calling method getUpdates: { offset: 934597283, timeout: 600 }\n    at Bot.callMethod (/home/sysadmin/.telegrambots/shell-bot/node_modules/botgram/lib/bot.js:102:18)\n    at Bot.consumeUpdates (/home/sysadmin/.telegrambots/shell-bot/node_modules/botgram/lib/bot.js:201:8)\n    at Bot.<anonymous> (/home/sysadmin/.telegrambots/shell-bot/node_modules/botgram/lib/bot.js:219:20)\n    at handleBody (/home/sysadmin/.telegrambots/shell-bot/node_modules/botgram/lib/bot.js:157:25)\n    at IncomingMessage.<anonymous> (/home/sysadmin/.telegrambots/shell-bot/node_modules/botgram/lib/bot.js:146:33)\n    at emitNone (events.js:111:20)\n    at IncomingMessage.emit (events.js:208:7)\n    at endReadableNT (_stream_readable.js:1064:12)\n    at _combinedTickCallback (internal/process/next_tick.js:138:11)\n    at process._tickCallback (internal/process/next_tick.js:180:9)',
  message: 'getUpdates failed: Error: socket hang up',
  err: { Error: socket hang up
    at createHangUpError (_http_client.js:331:15)
    at TLSSocket.socketOnEnd (_http_client.js:423:23)
    at emitNone (events.js:111:20)
    at TLSSocket.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) code: 'ECONNRESET' },
  req:
   { Error: When calling method getUpdates: { offset: 934597283, timeout: 600 }
    at Bot.callMethod (/home/sysadmin/.telegrambots/shell-bot/node_modules/botgram/lib/bot.js:102:18)
    at Bot.consumeUpdates (/home/sysadmin/.telegrambots/shell-bot/node_modules/botgram/lib/bot.js:201:8)
    at Bot.<anonymous> (/home/sysadmin/.telegrambots/shell-bot/node_modules/botgram/lib/bot.js:219:20)
    at handleBody (/home/sysadmin/.telegrambots/shell-bot/node_modules/botgram/lib/bot.js:157:25)
    at IncomingMessage.<anonymous> (/home/sysadmin/.telegrambots/shell-bot/node_modules/botgram/lib/bot.js:146:33)
    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)
     method: 'getUpdates',
     parameters: { offset: 934597283, timeout: 600 },
     message: 'When calling method getUpdates: { offset: 934597283, timeout: 600 }' } }

If it is a network error i'm sure is temporary, there must be something that can be done to avoid the crash and keep the bot working.

Cheers!

mildsunrise commented 4 years ago

If I understand correctly, only these messages are printed and then the bot crashes? (i.e. node server exits?)

samthelion17 commented 4 years ago

That's correct, 'node server' exits. I forgot to add in my first message that i'm running Ubuntu Linux 18.04.4 up-to-date with node v8.10.0 and using a proxy server. At the time the bot starts everything works good, it only crashes time later, although i don't know how much time...

andrewlytvyn commented 4 years ago

i have some problem also(

andrewlytvyn commented 4 years ago

I found simple solution, just comment console.log commands. I'm using pm2, and should been to restart instans once per day for prevent stopping bot.