windkh / node-red-contrib-telegrambot

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

Error stopping node: Close timed out #248

Closed JanOosthuizen closed 2 years ago

JanOosthuizen commented 2 years ago

Hi. Can someone help me.

I loaded node-red-contrib-telegrambot on Raspberry Pi4. I did create a bot with botfather.( Token ,user, chatID) If I test sending messages via the Pi web browser it works. But I can not get it working via Node-Red ! As soon as a configure & Deploy Node-Red I get string[36] "Error stopping node: Close timed out" Do you have any suggestions?

The software I am using: Debian 11.3 Bullseye (64Bit) Running on external SSD Linux 5.15.32-v8+ arm64 LE Node-RED version: v2.2.2 Node.js version: v14.19.3 node-red-contrib-telegrambot V11.3 mosquitto is an MQTT v5.0/v3.1.1/v3.1 broker. influxdb 1.8.10-1
Grafana 8.5

sanyafifa commented 2 years ago

I have such an error when switching Internet channels ISP1 and ISP2

JanOosthuizen commented 2 years ago

What is funny to me is that I can send messages via the Raspberry Pi web browser.

windkh commented 2 years ago

Close timeout means that the telegram bot node was about to be closed and a timeout occured triggered by node-red

JanOosthuizen commented 2 years ago

How can I insure Node-Red connect do to the telegram bot (Don't get timeout). I know from the web browser the Token ,user, chatID are correct. 1) Is there other configuration I need to do in node-Red/Pi except for "node-red-contrib-telegrambot" 2) How can I get closer to the problem?

JanOosthuizen commented 2 years ago

I am pretty sure the problem is in Node-Red. Because I can successfully send Telegram messages from the DuckDickGo web browser in the Raspberry Pi to my telegrambot. 1) How can I do some diagnostics to get closer to the problem? 2) Does telegram use a specific port?

JanOosthuizen commented 2 years ago

I have such an error when switching Internet channels ISP1 and ISP2

Do you think it can be the same problem since I am able the send messages with the Pi web browser?

windkh commented 2 years ago

Sending messages is different to receiving. Receiving is done using via polling the server for new messages.

Close Timeout can only happen if you redeploy the nodes: this stops polling and will restart it again. If for some reason the polling can not be stopped in time, then you get a timeout error which is basically triggered by node-red. (Don't ask me how long the timeout is by default).

I must check if the timeout of the call to the telegram server can be changed in a way that it is shorter than the node-red timeout. An alternative could be to not await the call at all.

windkh commented 2 years ago

Timeout is set to 10s in 11.5.0 as node-red raises the error at about 12 seconds. Please let me know if the error is gone then.

JanOosthuizen commented 2 years ago

Hi windkh

I only get the error when I deploy.

Note: When using my Debug node for fault finding , both telegram Receiver and Sending node-
I don't get ANY messages from on the First output or Second output (Send error to second output) using debug node.

It feels to me like the Telgram node "service" is not running. Does telegram on the Pi have a service that needs to run? Maybe I must try and install "node-red-contrib-telegrambot" from terminal and not from the pallet, will it make a difference?

The Telegram Bot is working. Because I get response (Read & Write) from Telegram Group when I test it with web browser and with Phyton !

windkh commented 2 years ago

Have you tested the latest version yet?

JanOosthuizen commented 2 years ago

Yes, I did. I am on V 11.6.0 After uninstalling the latest version, I did restart the Raspberry Pi.

windkh commented 2 years ago

@JanOosthuizen I changed the timeout to 10s in 11.6.0 which should be enough. However on the Pi it still causes the same problem.

When you redepoly, the config node will try to stop the polling cycle for new messages from the telegram server. If this is successful it will restart. The message itself is generated when node-red itself does not want to wait any longer for the config node. In short. The bot should still work even when this message is created.

As the error is created by the config node, nothing will be send from the receiver or sender node.

Can you send me the flow so I can see your configuration node... maybe something is wrong there. Have you tried to install node-red on your computer instead of your Pi: does it run there?

JanOosthuizen commented 2 years ago

Thanks for the tip- ...install node-red on your computer instead of your Pi

This morning I installed Node-Red on my Windows 10 PC. I installed "node-red-contrib-telegrambot" from the Pallete. And for the first time the simple "/echo" test is working ! (Same configuration that I use on Pi)

For some reason the Telegram node is not working on the Raspberry Pi.

JanOosthuizen commented 2 years ago

Note: I also did not get errors when I deploy

windkh commented 2 years ago

@JanOosthuizen I think you only get these error during deploy... or do you have them elswhere?

JanOosthuizen commented 2 years ago

I only have this one error, and I only get it when I have a Telegram node inside my flow. (If I delete the node I don't get any errors when I deploy)

I notice that deploy takes longer (+-12Sec) as soon as I have any telegram Node inside my flow. On the Windows PC deploy with telegram node is fast.(<1sec)

JanOosthuizen commented 2 years ago

My flow is simple: I only have one receive node (Bot-Name,Token, User & chat ID) with a Debug message connect to it.

JanOosthuizen commented 2 years ago

I see the Receiving Node Status on the flow of the Pi shows "Connected" while the Receiving Node Status on the flow of the Windows PC shows "Polling"

JanOosthuizen commented 2 years ago

When I export my flow I see the port that is used is 8443. Can it be that some other software use this port?

JanOosthuizen commented 2 years ago
{
    "id": "34757404ea38eaee",
    "type": "tab",
    "label": "Telegram Flow",
    "disabled": false,
    "info": "",
    "env": []
},
{
    "id": "28b3b6494f31acc7",
    "type": "debug",
    "z": "34757404ea38eaee",
    "name": "",
    "active": true,
    "tosidebar": true,
    "console": false,
    "tostatus": false,
    "complete": "false",
    "statusVal": "",
    "statusType": "auto",
    "x": 850,
    "y": 280,
    "wires": []
},
{
    "id": "ba3e4aed643ec03e",
    "type": "telegram receiver",
    "z": "34757404ea38eaee",
    "name": "NameRx",
    "bot": "688b431fdc55bec4",
    "saveDataDir": "",
    "filterCommands": false,
    "x": 640,
    "y": 280,
    "wires": [
        [
            "28b3b6494f31acc7"
        ],
        []
    ]
},
{
    "id": "688b431fdc55bec4",
    "type": "telegram bot",
    "botname": "BotNameProb1",
    "usernames": "BotUserProb1_bot",
    "chatids": "-749652958       ",
    "baseapiurl": "",
    "updatemode": "polling",
    "pollinterval": "300",
    "usesocks": false,
    "sockshost": "",
    "socksport": "6667",
    "socksusername": "anonymous",
    "sockspassword": "",
    "bothost": "",
    "botpath": "",
    "localbotport": "8443",
    "publicbotport": "8443",
    "privatekey": "",
    "certificate": "",
    "useselfsignedcertificate": false,
    "sslterminated": false,
    "verboselogging": false
}

]

JanOosthuizen commented 2 years ago

I Uninstalled - Reinstall -"node-red-contrib-telegrambot" in the hope it will work. It did not but I did copy the install log. Not sure if this is the problem and if it is the problem, how do I fix it?

2022-07-04T18:21:29.563Z Install : node-red-contrib-telegrambot 11.6.0 2022-07-04T18:21:29.626Z npm install --no-audit --no-update-notifier --no-fund --save --save-prefix=~ --production --engine-strict node-red-contrib-telegrambot@11.6.0 2022-07-04T18:21:35.404Z [err] npm 2022-07-04T18:21:35.404Z [err] WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142 2022-07-04T18:21:35.590Z [err] npm 2022-07-04T18:21:35.590Z [err] WARN deprecated request-promise@4.2.6: request-promise has been deprecated because it extends the now deprecated request package, see https://github.com/request/request/issues/3142 2022-07-04T18:21:45.994Z [err] npm WARN 2022-07-04T18:21:45.995Z [err] deprecated uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details. 2022-07-04T18:21:53.789Z [out] + node-red-contrib-telegrambot@11.6.0 2022-07-04T18:21:53.789Z [out] added 101 packages from 131 contributors in 22.881s

JanOosthuizen commented 2 years ago

I found the problem: To many underlying errors/faults in total on my flows. Little bit of cleanup and maintenance and then I got no more timeout faults on Node-Red when using this bot node.