windkh / node-red-contrib-telegrambot

Telegram bot nodes for node-red.
Other
256 stars 116 forks source link

"Error stopping node: Close timed out" and no communication to telegram.org #282

Closed aaarghh closed 1 year ago

aaarghh commented 1 year ago

Running 14.8.7 in Node-RED 3.0.2 on Raspberry Pi 4 with raspbian bullseye. Node installs from the palette without errors.

Bot is set up and the configuration node properly set with bot name and API key. After deploy, the status of Receiver or Command nodes shows "connected". Verbose logging is turned on.

However, no communication is going out. There are no entries in the Node-RED log or in var/log/syslog that would give (me) a clue. (At least none which I could identifiy when searching for "telegram")

Was suspecting Pi-hole to block telegram.org (low chances anyway, as I can access it from any other device in my network). Confirmed not to be blocked. Yes, a simple ping from the Raspberry to telegram.org would have served the same purpose, but you never know.

When looking at the detailed DNS queries coming from the Raspberry Pi running Node-RED, it turns out that telegram.org is never listed at all. When running "ping api.telegram.org", entries for sure start to appear.

The only other observation so far is the "Error stopping node: Close timed out" message from the nodes when deploying.

My conclusion so far (and the absolute end of my limited troubleshooting skills): node-red-contrib-telegrambot does not communicate to the telegram server. But why, I do not know ...

What could I do to diagnose this further?

Any form of help is greatly appreciated!

windkh commented 1 year ago

@aaarghh "Error stopping node, ..." only indicates that while redepoly the long poll did not return in time. Which is then ignored.

Basically a call to "https://api.telegram.org" is made for getting the latest messages (if you are using polling). A ping uses the ICMP protocol which only tells you that name resolution and the route works fine. However if something is blocking the traffic at all you should get an error.

From here it is hard to tell what is going on. I can only guess ... First make sure that the token is correct and that you did not have trailing or leading whitespaces around the token in the config node.

Then you should try to call this from outside node-red (please replace with your token) https://api.telegram.org/bot/getMe

Did you try the control node yet? Does it generate some output?

aaarghh commented 1 year ago

The call to https://api.telegram.org/bot/getMe works fine with my API key (copied from the config node, so no extra spaces there). It also works from Node-RED via the http request node, so it is not a communication issue of that Raspberry Pi.

The control node (took the example provided here and used my config) just returns the commands injected, but nothing else. If I enable "Check network connection" it starts to contact api.telegram.org (as confirmed via DNS logs) and returns "isOnline: true"

windkh commented 1 year ago

Hm maybe you should show this to me in a teams meeting. What do you think?

aaarghh commented 1 year ago

That would be awfully nice! Very much appreciated. Will send an email with contacts.

windkh commented 1 year ago

@aaarghh please give us an update here so that others that have the same problems can read it.

aaarghh commented 1 year ago

Did some further tests on a different platform (Lenovo M73 tiny): 1) Installed Debian 2) Installed node.js with curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash - &&\ sudo apt-get install -y nodejs 3) Installed Node-RED with sudo npm install -g --unsafe-perm node-red 4) Imported node-red-contrib-telegrambot, configured settings 5) Found it to be working flawlessly.

Decided to start over again 1) Cleanly reinstalled Debian 2) This time, used the installer script for Raspberry-Pi (which is also suited for Debian, as per description) bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered) 3) Imported node-red-contrib-telegrambot, configured settings 4) As dead and unresponsive as on my Pi4

Not 100% sure if there is a causation, but the outcomes hint at a difference in the two methods of installation.

FISEChris1337 commented 1 year ago

Just removed node-red with npm and reinstall with npm and it worked ... but can we find out why?

497 sudo systemctl stop nodered 498 npm -g remove node-red 499 sudo npm -g remove node-red 500 sudo npm -g remove node-red-admin 501 rm -rf ~/.node-red 502 sudo npm install -g --unsafe-perm node-red 503 sudo systemctl start nodered

i tried reinstall with bash already but this was not a success as this way

windkh commented 1 year ago

Hm I would also like to know why that kind of problem only occurs on the rpi.