Telegram HTTP Post sends message correctly, but Pi shows error

#1

I can use HTTP Post to send messages from a telegram bot into a chat. That works no problem and I get the message I send. However, even though I get the message the log on my Pi shows I had an unhandled error. I think these errors are causing my Pi to freeze up every few days.

HTTP Post I use is https://api.telegram.org/bot/Q
for example and in telegram my bot posts "Q" no problem. Anytime I do this the pi shows:

Mar 29 20:02:09 Dresser_Pi Node-RED[338]: Unhandled rejection Error: ETELEGRAM: 400 Bad Request: message text is empty
Mar 29 20:02:09 Dresser_Pi Node-RED[338]: at request.then.resp (/home/pi/.no de-red/node_modules/node-telegram-bot-api/src/telegram.js:280:15)
Mar 29 20:02:09 Dresser_Pi Node-RED[338]: at tryCatcher (/home/pi/.node-red/ node_modules/request-promise/node_modules/bluebird/js/release/util.js:16:23)
Mar 29 20:02:09 Dresser_Pi Node-RED[338]: at Promise._settlePromiseFromHandl er (/home/pi/.node-red/node_modules/request-promise/node_modules/bluebird/js/rel ease/promise.js:512:31)
Mar 29 20:02:09 Dresser_Pi Node-RED[338]: at Promise._settlePromise (/home/p i/.node-red/node_modules/request-promise/node_modules/bluebird/js/release/promis e.js:569:18)
Mar 29 20:02:09 Dresser_Pi Node-RED[338]: at Promise._settlePromise0 (/home/ pi/.node-red/node_modules/request-promise/node_modules/bluebird/js/release/promi se.js:614:10)
Mar 29 20:02:09 Dresser_Pi Node-RED[338]: at Promise._settlePromises (/home/ pi/.node-red/node_modules/request-promise/node_modules/bluebird/js/release/promi se.js:694:18)
Mar 29 20:02:09 Dresser_Pi Node-RED[338]: at _drainQueueStep (/home/pi/.node -red/node_modules/request-promise/node_modules/bluebird/js/release/async.js:138: 12)
Mar 29 20:02:09 Dresser_Pi Node-RED[338]: at _drainQueue (/home/pi/.node-red /node_modules/request-promise/node_modules/bluebird/js/release/async.js:131:9)
Mar 29 20:02:09 Dresser_Pi Node-RED[338]: at Async._drainQueues (/home/pi/.n ode-red/node_modules/request-promise/node_modules/bluebird/js/release/async.js:1 47:5)
Mar 29 20:02:09 Dresser_Pi Node-RED[338]: at Immediate.Async.drainQueues [as _onImmediate] (/home/pi/.node-red/node_modules/request-promise/node_modules/blu ebird/js/release/async.js:17:14)
Mar 29 20:02:09 Dresser_Pi Node-RED[338]: at runCallback (timers.js:696:18)
Mar 29 20:02:09 Dresser_Pi Node-RED[338]: at tryOnImmediate (timers.js:667:5 )
Mar 29 20:02:09 Dresser_Pi Node-RED[338]: at processImmediate (timers.js:649 :5)

Any ideas why the message goes through and yet I still get an error for an empty message?

0 Likes

#2

I am surprised not to see a node-red node at the top level. How are you calling node-red-telegram-bot?

0 Likes

#3

I am not sure I understand the question, but the problem is coming from telegram receive nodes.

Typing that sentence gave me a new idea, so I may have the problem narrowed. I had thought it was specifically using POST to send a message that caused the issue, so I just tested an inject node triggering a bot message, which my second bot received and the error occurred again.

I have a handful of receive nodes all searching the same channel. I know they all get the messages because each node has no problem reading the text and triggering events independently, but could one read it "first" and the other receive nodes think its empty?

0 Likes

#4

Stop and restart node red in a terminal and post the log starting from the welcome message to the point you get the crash. That may show something useful.

0 Likes

#5

Alright its been a while because I reverted to an older instance and slowly changed things one by one. It crashed today, so here is everything I know that happened. PS I think it has something to do with an exec node I use to arp scan my network to check for my IP every couple seconds, but idk why thats an issue, ive done that for a while now and never had problems.

So I come home for lunch at 1215 and see my monitor connected to my Pi showing time, weather, etc is frozen showing a time around 9am.

Putty times out and node red server on my browser does not work.

Node-Red is still responsive to events. I can still use tasker to HTTP Post to telegram, which node red uses with MQTT to trigger things. For example I could still use node red MQTT to turn on relays and such.

At the same time, a door sensor I have in deep sleep until the door is opened and connects to MQTT was not working. Seemingly any device that had already established an MQTT connection (pi is the broker) was working but a new device couldn't connect to the Pi?

Since I could not access the Pi at all I had to just kill the power. Upon reboot everything works fine. I ran cat /var/log/syslog and have attached what it shows. It looks very busy because of the error thrown by telegram for the "message content empty" which I have shown in the beginning of this thread. Thats annoying, but I dont think its the problem.

Around 845 my sudo arp scan stops working, don't know why. After that, at 917, the Pi is still doing things. It is seemingly on and running, but still has all the symptoms mentioned above.

All the telegram issues around 12 are HTTP posts I did to confirm it still saw them.

I have no idea what is happening at 1217. I think I was outside with my dog, so It wasnt anything I did, but it looks like Node-red was restarted? I didn't notice anything working on the monitor, but couldnt see the log so I did not know it restarted. I pulled power shortly after and went back to work. Plugged it back in around 526.

This is a lot, but I have no idea whats going on so I figure id be thorough. Log is shown below. Thank you!

0 Likes

#6

Log is tool long to post. I put it in a txt. Let me know if there is a
better way.

CrashLog4-16.txt (127.6 KB)

0 Likes

#7

The items stamped as 12:17, starting with
Apr 16 12:17:05 Dresser_Pi systemd-modules-load[96]: Inserted module 'i2c_dev'
are actually the start of the boot sequence. Note that the time appears to have gone backwards. The last stuff before you switched it off are the 16:21 entries, before you pulled the plug.
The reason it is failing may be related to the repeated node-red crashes you are getting
Apr 16 12:21:27 Dresser_Pi Node-RED[338]: Unhandled rejection Error: ETELEGRAM: 400 Bad Request: message text is empty
which at the very least indicates a problem with that node which should be reported.
There may be an underlying issue though. It does not explain why you could not connect via putty.
I have just looked back at earlier posts, are you using a telegram node or are you doing it yourself?

0 Likes

#8

I am using a telegram node. If i use an inject node to a telegram send node, a telegram receive node sees the message and the error occurs. Again, I can see the message, if I didn't see the error I would think everything was working normally.

I also include msg.payload. chatid, type, and content in the send node so message text should not be empty as the error suggests

0 Likes