OctoPrint-Telegram
OctoPrint-Telegram copied to clipboard
Many request to api.telegram.org
This plugin makes multiple requests to api.telegram.org. Seems to be every 30 seconds. I'm not sure if this is "normal" behavior. As a work around I created a manual entry in the /etc/hosts file to stop the constant lookups hammering my DNS server
I’m not sure I understand where the bug is. Yes, it is normal for a telegram bot to poll for new messages, once every 30 seconds seems pretty fair compromise between responsiveness and load. If a DNS can’t handle a simple cacheable request every 30 seconds I would be concerned by the DNS server capabilities rather than by the rightfulness of the requests.... Your DNS should receive the request and just reply with the same value you entered in the /et/hosts for around 24 hours, then it should check again if the value it’s still correct... you should have absolutely no need for hard coding it in your hosts file
Can we not optimise this i.e. don't poll if OctoPrint is offline?
If by offline you mean power down than no request is issued by a device that is powered off, if you mean disconnected from the internet then the only way to know that is by submitting a request...
If you mean reduce the poll frequency when multiple "unavailable host" responses are returned, feel free to submit a pull request implementing such a feature: the plugin author is generally welcoming any improvement.
Personally I don't feel the need for that: I'm generally connected to the internet and my 20€ home router happily complies with the current poll frequency.
When I say offline, I am referring to the printer being offline or disconnected. As I understand this plugin is only used when the printer is online.
No, the plugin works fine when the printer is not connected. That's what the /con command is for.
In my opinion the problem is that the TTL of api.telegram.org DNS entry is 300 seconds, that provokes the frequent DNS queries to refresh the value every 5 minutes. I don't understand why they use such a low value, I don't think the IP changes that often to justify that.