Telegram_bot setwebhook timeout need help

I am having issues with the telegram_bot integration since converting from the polling connection method to webhooks.

When I restart home assistant 0.99.1 running in docker, I get a notification that the integration did not load properly. However, if I restart homeassistant, the integration then loads and works as expected.

At this point I am kind of sick of having to restart multiple times in a row. Does anyone have any suggestions?

I found these two related issues in github from 2017…first one suggested increasing timeout to 10s…second one added three retries and then shorted timeout back to the current 5 seconds:


Here is the error in my logs:

Error setting up platform webhooks
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/telegram_bot/__init__.py", line 292, in async_setup
    receiver_service = await platform.async_setup_platform(hass, p_config)
  File "/usr/src/homeassistant/homeassistant/components/telegram_bot/webhooks.py", line 63, in async_setup_platform
    result = await hass.async_add_job(_try_to_set_webhook)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/telegram_bot/webhooks.py", line 57, in _try_to_set_webhook
    return bot.setWebhook(handler_url, timeout=5)
  File "/usr/local/lib/python3.7/site-packages/telegram/bot.py", line 65, in decorator
    result = func(self, *args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/telegram/bot.py", line 2070, in set_webhook
    result = self._request.post(url_, data, timeout=timeout)
  File "/usr/local/lib/python3.7/site-packages/telegram/utils/request.py", line 309, in post
    headers={'Content-Type': 'application/json'})
  File "/usr/local/lib/python3.7/site-packages/telegram/utils/request.py", line 233, in _request_wrapper
    raise NetworkError('{0} ({1})'.format(message, resp.status))
telegram.error.NetworkError: Conflict: terminated by other setWebhook (409)

Has this been resolved as I am seeing the same behavior having to restart HA multiple times to get Telegram integration to load successfully?