Under Python 3.1, when trying to run this code:
from urllib import request
def test():
request.urlopen("http://www.google.com")
test()
I get an HTTP 409 error. The stack trace is:
Traceback (most recent call last):
File "C:UsersBeauPythonpokescrape.py", line 6, in <module>
test()
File "C:UsersBeauPythonpokescrape.py", line 4, in test
request.urlopen("http://www.google.com")
File "C:Program FilesPythonliburllibrequest.py", line 119, in urlopen
return _opener.open(url, data, timeout)
File "C:Program FilesPythonliburllibrequest.py", line 353, in open
response = meth(req, response)
File "C:Program FilesPythonliburllibrequest.py", line 465, in http_response
'http', request, response, code, msg, hdrs)
File "C:Program FilesPythonliburllibrequest.py", line 385, in error
result = self._call_chain(*args)
File "C:Program FilesPythonliburllibrequest.py", line 325, in _call_chain
result = func(*args)
File "C:Program FilesPythonliburllibrequest.py", line 560, in http_error_302
return self.parent.open(new, timeout=req.timeout)
File "C:Program FilesPythonliburllibrequest.py", line 353, in open
response = meth(req, response)
File "C:Program FilesPythonliburllibrequest.py", line 465, in http_response
'http', request, response, code, msg, hdrs)
File "C:Program FilesPythonliburllibrequest.py", line 391, in error
return self._call_chain(*args)
File "C:Program FilesPythonliburllibrequest.py", line 325, in _call_chain
result = func(*args)
File "C:Program FilesPythonliburllibrequest.py", line 473, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
And the actual error, as printed, is:
urllib.error.HTTPError: HTTP Error 409: Conflict
I’m behind a proxy set via a configuration script; I’ve had no issues regarding internet connection.
Why on earth am I getting an HTTP 409 error?
Please answer these questions before submitting your issue. Thanks!
- What version of pyTelegramBotAPI are you using?
pyTelegramBotAPI 4.7.1
- What OS are you using?
docker images in Mac OS Ventura and Ubuntu 22.04 on Raspberry Pi 4. Same behaviour.
- What version of python are you using?
3.8-buster
3.9-bullseye
Same behaviour.
The bot runs fine but the following appears continuously in the logs. First every few seconds, some time later about 30+ seconds every exception.
2022-11-02 10:02:01,917 (init.py:1089 MainThread) ERROR — TeleBot: «Exception traceback:
Traceback (most recent call last):
File «/usr/local/lib/python3.8/site-packages/telebot/init.py», line 1077, in __threaded_polling
polling_thread.raise_exceptions()
File «/usr/local/lib/python3.8/site-packages/telebot/util.py», line 116, in raise_exceptions
raise self.exception_info
File «/usr/local/lib/python3.8/site-packages/telebot/util.py», line 98, in run
task(*args, **kwargs)
File «/usr/local/lib/python3.8/site-packages/telebot/init.py», line 653, in __retrieve_updates
updates = self.get_updates(offset=(self.last_update_id + 1),
File «/usr/local/lib/python3.8/site-packages/telebot/init.py», line 627, in get_updates
json_updates = apihelper.get_updates(self.token, offset, limit, timeout, allowed_updates, long_polling_timeout)
File «/usr/local/lib/python3.8/site-packages/telebot/apihelper.py», line 334, in get_updates
return _make_request(token, method_url, params=payload)
File «/usr/local/lib/python3.8/site-packages/telebot/apihelper.py», line 162, in _make_request
json_result = _check_result(method_name, result)
File «/usr/local/lib/python3.8/site-packages/telebot/apihelper.py», line 189, in _check_result
raise ApiTelegramException(method_name, result, result_json)
telebot.apihelper.ApiTelegramException: A request to the Telegram API was unsuccessful. Error code: 409. Description: Conflict: terminated by other getUpdates request; make sure that only one bot instance is running
Obviously no more than one instance running.
Thanks in advance
Obviously no more than one instance running.
Not obviously without any details. If Telegram says it does — it definitely does.
Check your code, may be it runs in parallel.
But this is the code 😀 :
from config import *
import telebot
bot = telebot.TeleBot(TELEGRAM_TOKEN)
@bot.message_handler(commands=[«start», «help»])
def cmd_start(message):
bot.reply_to(message, «Hi!»)
if name == «main«:
print(«Starting bot»)
bot.infinity_polling()
print(«End»)
Maybe when one run is finished, the Telegram API does not know so the next bot execution triggers the message?
print("Starting
bot»)
- Show the console output after program starts and before Telegram error.
- Show the config which you imports.
Nothing happens without reasons. The only thing is to find the problem in your code.
Console output:
Starting bot
2022-11-03 13:45:22,690 (init.py:1087 MainThread) ERROR — TeleBot: «Threaded polling exception: A request to the Telegram API was unsuccessful. Error code: 409. Description: Conflict: terminated by other getUpdates request; make sure that only one bot instance is running»
2022-11-03 13:45:22,691 (init.py:1089 MainThread) ERROR — TeleBot: «Exception traceback:
Traceback (most recent call last):
File «/home/user/.local/lib/python3.10/site-packages/telebot/init.py», line 1077, in __threaded_polling
polling_thread.raise_exceptions()
File «/home/user/.local/lib/python3.10/site-packages/telebot/util.py», line 116, in raise_exceptions
raise self.exception_info
File «/home/user/.local/lib/python3.10/site-packages/telebot/util.py», line 98, in run
task(*args, **kwargs)
File «/home/user/.local/lib/python3.10/site-packages/telebot/init.py», line 653, in __retrieve_updates
updates = self.get_updates(offset=(self.last_update_id + 1),
File «/home/user/.local/lib/python3.10/site-packages/telebot/init.py», line 627, in get_updates
json_updates = apihelper.get_updates(self.token, offset, limit, timeout, allowed_updates, long_polling_timeout)
File «/home/user/.local/lib/python3.10/site-packages/telebot/apihelper.py», line 334, in get_updates
return _make_request(token, method_url, params=payload)
File «/home/user/.local/lib/python3.10/site-packages/telebot/apihelper.py», line 162, in _make_request
json_result = _check_result(method_name, result)
File «/home/user/.local/lib/python3.10/site-packages/telebot/apihelper.py», line 189, in _check_result
raise ApiTelegramException(method_name, result, result_json)
telebot.apihelper.ApiTelegramException: A request to the Telegram API was unsuccessful. Error code: 409. Description: Conflict: terminated by other getUpdates request; make sure that only one bot instance is running
«
The config.py is just one line,
TELEGRAM_TOKEN = «mybotprivatetoken»
Can you try to simply remove this line?
if name == "main":
Everything is fine for me.
Содержание
- «HTTP Error 409: Conflict» when using urllib.request.urlopen()
- 3 Answers 3
- Related
- Hot Network Questions
- Subscribe to RSS
- Хелп, как исправить ошибку телеграмм бота 409 conflict на питон?
- TeleBot:A request to the Telegram API was unsuccessful #737
- Comments
- Threaded polling exception 409 «make sure that only one bot instance is running» #1778
- Comments
- Footer
«HTTP Error 409: Conflict» when using urllib.request.urlopen()
Under Python 3.1, when trying to run this code:
I get an HTTP 409 error. The stack trace is:
And the actual error, as printed, is:
I’m behind a proxy set via a configuration script; I’ve had no issues regarding internet connection.
Why on earth am I getting an HTTP 409 error?
3 Answers 3
I was running into this problem too (also from Lancaster, as it happens) and found that if I set the environment variable http_proxy, Python would use it. In this case (on Windows) it would be:
Edit: Thanks Beau Martínez for the *nix fix.
The HTTP error you’re seeing is one the remote end (or the proxy) is giving you. HTTP Error 409 is indeed ‘Conflict’, which usually means there were conflicting requests being made. If you are indeed using a proxy I would suspect that being the source of the 409, but more debugging would be in order. Either use a tool like wireshark to analyze the actual traffic, or use http.client.HTTPConnection directly and turn on its debugging.
It turns out I had to manually set the proxy in-code. I’m assuming this was because I was using an automated proxy script.
For anybody with a similar issue, here’s the code I used:
Hot Network Questions
To subscribe to this RSS feed, copy and paste this URL into your RSS reader.
Site design / logo © 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA . rev 2023.1.14.43159
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.
Источник
Хелп, как исправить ошибку телеграмм бота 409 conflict на питон?
Помогите, как исправить ошибку 409 conflict
Traceback (most recent call last):
File «D:pythontelebotutil.py», line 59, in run
task(*args, **kwargs)
File «D:pythontelebot__init__.py», line 158, in __retrieve_updates
updates = self.get_updates(offset=(self.last_update_id + 1), timeout=timeout)
File «D:pythontelebot__init__.py», line 128, in get_updates
json_updates = apihelper.get_updates(self.token, offset, limit, timeout, allowed_updates)
File «D:pythontelebotapihelper.py», line 180, in get_updates
return _make_request(token, method_url, params=payload)
File «D:pythontelebotapihelper.py», line 56, in _make_request
return _check_result(method_name, result)[‘result’]
File «D:pythontelebotapihelper.py», line 75, in _check_result
raise ApiException(msg, method_name, result)
telebot.apihelper.ApiException: A request to the Telegram API was unsuccessful. The server returned HTTP 409 Conflict. Response body:
[b’<«ok»:false,»error_code»:409,»description»:»Conflict: terminated by other getUpdates request; make sure that only one bot instance is running»>‘]
»
2018-07-14 17:15:56,933 (__init__.py:299 MainThread) ERROR — TeleBot: «A request to the Telegram API was unsuccessful. The server returned HTTP 409 Conflict. Response body:
[b’<«ok»:false,»error_code»:409,»description»:»Conflict: terminated by other getUpdates request; make sure that only one bot instance is running»>‘]»
2018-07-14 17:16:00,833 (util.py:65 PollingThread) ERROR — TeleBot: «ApiException occurred, args=(‘A request to the Telegram API was unsuccessful. The server returned HTTP 409 Conflict. Response body:n[b’<«ok»:false,»error_code»:409,»description»:»Conflict: terminated by other getUpdates request; make sure that only one bot instance is running»>’]’,)
На питоне, я знаю что это означает запуск бота с двух клиентов но я запускаю только с одного, с pycharm,в чем проблема, подскажите.
P.s Скрипт бота в комменты скину если нужно !
Источник
TeleBot:A request to the Telegram API was unsuccessful #737
Please answer these questions before submitting your issue. Thanks!
What version of pyTelegramBotAPI are you using?
pyTelegramBotAPI==3.6.7
What OS are you using?
Ubuntu 18.04.
What version of python are you using?
3.7
After some hours of running the Bot in .polling() mode, there is some issue with the Telegram API but then the Bot stops working with
Is there a way to catch this exception so the bot doesn’t stop polling?
The text was updated successfully, but these errors were encountered:
I use supervisor to monitor the bot process, when process exit, supervisor will restart it
I used try except loop but still it will raise many exceptions . and bot terminates
finally resorted to my own
I got this error:
telebot.apihelper.ApiException: A request to the Telegram API was unsuccessful. The Server returned HTTP 409 conflict.
I got this error:
telebot.apihelper.ApiException: A request to the Telegram API was unsuccessful. The Server returned HTTP 409 conflict.
the whole message is :
it because you run one more instance request to ‘getUpdates’
I got this error:
telebot.apihelper.ApiException: A request to the Telegram API was unsuccessful. The Server returned HTTP 409 conflict.
the whole message is :
it because you run one more instance request to ‘getUpdates’
Please tell me how to solve this issue.
Thanks in advance
I got this error:
telebot.apihelper.ApiException: A request to the Telegram API was unsuccessful. The Server returned HTTP 409 conflict.
the whole message is :
it because you run one more instance request to ‘getUpdates’
Please tell me how to solve this issue.
Thanks in advance
- you run one more program instance at the same time, check the process on the server, kill one of them.
- maybe someone stole the token of your bot, chat with botfather, revoke the token, then run another instance using the new token.
I got this error:
telebot.apihelper.ApiException: A request to the Telegram API was unsuccessful. The Server returned HTTP 409 conflict.
the whole message is :
it because you run one more instance request to ‘getUpdates’
Please tell me how to solve this issue.
Thanks in advance
- you run one more program instance at the same time, check the process on the server, kill one of them.
- maybe someone stole the token of your bot, chat with botfather, revoke the token, then run another instance using the new token.
I use this link to try to access to my bot: https://api.telegram.org/botToken/getUpdates:
then I got this one :
<«ok»:true,»result»:<«id»:1032572032,»is_bot»:true,»first_name»:»Rest_Bot»,»username»:»rest_chatbot»,»can_join_groups»:true,»can_read_all_group_messages»:false,»supports_inline_queries»:true>>
I got this error:
telebot.apihelper.ApiException: A request to the Telegram API was unsuccessful. The Server returned HTTP 409 conflict.
the whole message is :
it because you run one more instance request to ‘getUpdates’
Please tell me how to solve this issue.
Thanks in advance
- you run one more program instance at the same time, check the process on the server, kill one of them.
- maybe someone stole the token of your bot, chat with botfather, revoke the token, then run another instance using the new token.
I use this link to try to access to my bot: https://api.telegram.org/botToken/getUpdates:
then I got this one :
<«ok»:true,»result»:<«id»:1032572032,»is_bot»:true,»first_name»:»Rest_Bot»,»username»:»rest_chatbot»,»can_join_groups»:true,»can_read_all_group_messages»:false,»supports_inline_queries»:true>>
the message, looks like it works fine.
I got this error:
telebot.apihelper.ApiException: A request to the Telegram API was unsuccessful. The Server returned HTTP 409 conflict.
the whole message is :
it because you run one more instance request to ‘getUpdates’
Please tell me how to solve this issue.
Thanks in advance
- you run one more program instance at the same time, check the process on the server, kill one of them.
- maybe someone stole the token of your bot, chat with botfather, revoke the token, then run another instance using the new token.
I use this link to try to access to my bot: https://api.telegram.org/botToken/getUpdates:
then I got this one :
<«ok»:true,»result»:<«id»:1032572032,»is_bot»:true,»first_name»:»Rest_Bot»,»username»:»rest_chatbot»,»can_join_groups»:true,»can_read_all_group_messages»:false,»supports_inline_queries»:true>>
the message, looks like it works fine.
Yeah, but still getting same error..
I got this error:
telebot.apihelper.ApiException: A request to the Telegram API was unsuccessful. The Server returned HTTP 409 conflict.
the whole message is :
it because you run one more instance request to ‘getUpdates’
Please tell me how to solve this issue.
Thanks in advance
- you run one more program instance at the same time, check the process on the server, kill one of them.
- maybe someone stole the token of your bot, chat with botfather, revoke the token, then run another instance using the new token.
I use this link to try to access to my bot: https://api.telegram.org/botToken/getUpdates:
then I got this one :
<«ok»:true,»result»:<«id»:1032572032,»is_bot»:true,»first_name»:»Rest_Bot»,»username»:»rest_chatbot»,»can_join_groups»:true,»can_read_all_group_messages»:false,»supports_inline_queries»:true>>
the message, looks like it works fine.
Yeah, but still getting same error..
That’s weird.
Are you sure you are request to ‘getUpdates’ but not ‘getMe’, ‘getMe’ won’t result to ‘409 Conflict’.
I got this error:
telebot.apihelper.ApiException: A request to the Telegram API was unsuccessful. The Server returned HTTP 409 conflict.
the whole message is :
it because you run one more instance request to ‘getUpdates’
Please tell me how to solve this issue.
Thanks in advance
- you run one more program instance at the same time, check the process on the server, kill one of them.
- maybe someone stole the token of your bot, chat with botfather, revoke the token, then run another instance using the new token.
I use this link to try to access to my bot: https://api.telegram.org/botToken/getUpdates:
then I got this one :
<«ok»:true,»result»:<«id»:1032572032,»is_bot»:true,»first_name»:»Rest_Bot»,»username»:»rest_chatbot»,»can_join_groups»:true,»can_read_all_group_messages»:false,»supports_inline_queries»:true>>
the message, looks like it works fine.
Yeah, but still getting same error..
That’s weird.
Are you sure you are request to ‘getUpdates’ but not ‘getMe’, ‘getMe’ won’t result to ‘409 Conflict’.
Источник
Threaded polling exception 409 «make sure that only one bot instance is running» #1778
Please answer these questions before submitting your issue. Thanks!
- What version of pyTelegramBotAPI are you using?
docker images in Mac OS Ventura and Ubuntu 22.04 on Raspberry Pi 4. Same behaviour.
- What version of python are you using?
The bot runs fine but the following appears continuously in the logs. First every few seconds, some time later about 30+ seconds every exception.
2022-11-02 10:02:01,917 (init.py:1089 MainThread) ERROR — TeleBot: «Exception traceback:
Traceback (most recent call last):
File «/usr/local/lib/python3.8/site-packages/telebot/init.py», line 1077, in __threaded_polling
polling_thread.raise_exceptions()
File «/usr/local/lib/python3.8/site-packages/telebot/util.py», line 116, in raise_exceptions
raise self.exception_info
File «/usr/local/lib/python3.8/site-packages/telebot/util.py», line 98, in run
task(*args, **kwargs)
File «/usr/local/lib/python3.8/site-packages/telebot/init.py», line 653, in __retrieve_updates
updates = self.get_updates(offset=(self.last_update_id + 1),
File «/usr/local/lib/python3.8/site-packages/telebot/init.py», line 627, in get_updates
json_updates = apihelper.get_updates(self.token, offset, limit, timeout, allowed_updates, long_polling_timeout)
File «/usr/local/lib/python3.8/site-packages/telebot/apihelper.py», line 334, in get_updates
return _make_request(token, method_url, params=payload)
File «/usr/local/lib/python3.8/site-packages/telebot/apihelper.py», line 162, in _make_request
json_result = _check_result(method_name, result)
File «/usr/local/lib/python3.8/site-packages/telebot/apihelper.py», line 189, in _check_result
raise ApiTelegramException(method_name, result, result_json)
telebot.apihelper.ApiTelegramException: A request to the Telegram API was unsuccessful. Error code: 409. Description: Conflict: terminated by other getUpdates request; make sure that only one bot instance is running
Obviously no more than one instance running.
Thanks in advance
The text was updated successfully, but these errors were encountered:
Obviously no more than one instance running.
Not obviously without any details. If Telegram says it does — it definitely does.
Check your code, may be it runs in parallel.
But this is the code 😀 :
from config import *
import telebot
@bot.message_handler(commands=[«start», «help»])
def cmd_start(message):
bot.reply_to(message, «Hi!»)
if name == «main«:
print(«Starting bot»)
bot.infinity_polling()
print(«End»)
Maybe when one run is finished, the Telegram API does not know so the next bot execution triggers the message?
- Show the console output after program starts and before Telegram error.
- Show the config which you imports.
Nothing happens without reasons. The only thing is to find the problem in your code. 🙂
Starting bot
2022-11-03 13:45:22,690 (init.py:1087 MainThread) ERROR — TeleBot: «Threaded polling exception: A request to the Telegram API was unsuccessful. Error code: 409. Description: Conflict: terminated by other getUpdates request; make sure that only one bot instance is running»
2022-11-03 13:45:22,691 (init.py:1089 MainThread) ERROR — TeleBot: «Exception traceback:
Traceback (most recent call last):
File «/home/user/.local/lib/python3.10/site-packages/telebot/init.py», line 1077, in __threaded_polling
polling_thread.raise_exceptions()
File «/home/user/.local/lib/python3.10/site-packages/telebot/util.py», line 116, in raise_exceptions
raise self.exception_info
File «/home/user/.local/lib/python3.10/site-packages/telebot/util.py», line 98, in run
task(*args, **kwargs)
File «/home/user/.local/lib/python3.10/site-packages/telebot/init.py», line 653, in __retrieve_updates
updates = self.get_updates(offset=(self.last_update_id + 1),
File «/home/user/.local/lib/python3.10/site-packages/telebot/init.py», line 627, in get_updates
json_updates = apihelper.get_updates(self.token, offset, limit, timeout, allowed_updates, long_polling_timeout)
File «/home/user/.local/lib/python3.10/site-packages/telebot/apihelper.py», line 334, in get_updates
return _make_request(token, method_url, params=payload)
File «/home/user/.local/lib/python3.10/site-packages/telebot/apihelper.py», line 162, in _make_request
json_result = _check_result(method_name, result)
File «/home/user/.local/lib/python3.10/site-packages/telebot/apihelper.py», line 189, in _check_result
raise ApiTelegramException(method_name, result, result_json)
telebot.apihelper.ApiTelegramException: A request to the Telegram API was unsuccessful. Error code: 409. Description: Conflict: terminated by other getUpdates request; make sure that only one bot instance is running
«
The config.py is just one line,
Can you try to simply remove this line?
if name == «main»:
Removed, same result
Everything is fine for me.
© 2023 GitHub, Inc.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Источник
Threaded polling exception 409 «make sure that only one bot instance is running» #1778
Comments
setovi commented Nov 2, 2022
Please answer these questions before submitting your issue. Thanks!
- What version of pyTelegramBotAPI are you using?
docker images in Mac OS Ventura and Ubuntu 22.04 on Raspberry Pi 4. Same behaviour.
- What version of python are you using?
The bot runs fine but the following appears continuously in the logs. First every few seconds, some time later about 30+ seconds every exception.
2022-11-02 10:02:01,917 (init.py:1089 MainThread) ERROR — TeleBot: «Exception traceback:
Traceback (most recent call last):
File «/usr/local/lib/python3.8/site-packages/telebot/init.py», line 1077, in __threaded_polling
polling_thread.raise_exceptions()
File «/usr/local/lib/python3.8/site-packages/telebot/util.py», line 116, in raise_exceptions
raise self.exception_info
File «/usr/local/lib/python3.8/site-packages/telebot/util.py», line 98, in run
task(*args, **kwargs)
File «/usr/local/lib/python3.8/site-packages/telebot/init.py», line 653, in __retrieve_updates
updates = self.get_updates(offset=(self.last_update_id + 1),
File «/usr/local/lib/python3.8/site-packages/telebot/init.py», line 627, in get_updates
json_updates = apihelper.get_updates(self.token, offset, limit, timeout, allowed_updates, long_polling_timeout)
File «/usr/local/lib/python3.8/site-packages/telebot/apihelper.py», line 334, in get_updates
return _make_request(token, method_url, params=payload)
File «/usr/local/lib/python3.8/site-packages/telebot/apihelper.py», line 162, in _make_request
json_result = _check_result(method_name, result)
File «/usr/local/lib/python3.8/site-packages/telebot/apihelper.py», line 189, in _check_result
raise ApiTelegramException(method_name, result, result_json)
telebot.apihelper.ApiTelegramException: A request to the Telegram API was unsuccessful. Error code: 409. Description: Conflict: terminated by other getUpdates request; make sure that only one bot instance is running
Obviously no more than one instance running.
Thanks in advance
The text was updated successfully, but these errors were encountered:
Badiboy commented Nov 2, 2022
Obviously no more than one instance running.
Not obviously without any details. If Telegram says it does — it definitely does.
Check your code, may be it runs in parallel.
setovi commented Nov 2, 2022
But this is the code 😀 :
from config import *
import telebot
@bot.message_handler(commands=[«start», «help»])
def cmd_start(message):
bot.reply_to(message, «Hi!»)
if name == «main«:
print(«Starting bot»)
bot.infinity_polling()
print(«End»)
Maybe when one run is finished, the Telegram API does not know so the next bot execution triggers the message?
Badiboy commented Nov 3, 2022 •
- Show the console output after program starts and before Telegram error.
- Show the config which you imports.
Nothing happens without reasons. The only thing is to find the problem in your code. 🙂
setovi commented Nov 3, 2022 •
Starting bot
2022-11-03 13:45:22,690 (init.py:1087 MainThread) ERROR — TeleBot: «Threaded polling exception: A request to the Telegram API was unsuccessful. Error code: 409. Description: Conflict: terminated by other getUpdates request; make sure that only one bot instance is running»
2022-11-03 13:45:22,691 (init.py:1089 MainThread) ERROR — TeleBot: «Exception traceback:
Traceback (most recent call last):
File «/home/user/.local/lib/python3.10/site-packages/telebot/init.py», line 1077, in __threaded_polling
polling_thread.raise_exceptions()
File «/home/user/.local/lib/python3.10/site-packages/telebot/util.py», line 116, in raise_exceptions
raise self.exception_info
File «/home/user/.local/lib/python3.10/site-packages/telebot/util.py», line 98, in run
task(*args, **kwargs)
File «/home/user/.local/lib/python3.10/site-packages/telebot/init.py», line 653, in __retrieve_updates
updates = self.get_updates(offset=(self.last_update_id + 1),
File «/home/user/.local/lib/python3.10/site-packages/telebot/init.py», line 627, in get_updates
json_updates = apihelper.get_updates(self.token, offset, limit, timeout, allowed_updates, long_polling_timeout)
File «/home/user/.local/lib/python3.10/site-packages/telebot/apihelper.py», line 334, in get_updates
return _make_request(token, method_url, params=payload)
File «/home/user/.local/lib/python3.10/site-packages/telebot/apihelper.py», line 162, in _make_request
json_result = _check_result(method_name, result)
File «/home/user/.local/lib/python3.10/site-packages/telebot/apihelper.py», line 189, in _check_result
raise ApiTelegramException(method_name, result, result_json)
telebot.apihelper.ApiTelegramException: A request to the Telegram API was unsuccessful. Error code: 409. Description: Conflict: terminated by other getUpdates request; make sure that only one bot instance is running
«
The config.py is just one line,
Badiboy commented Nov 3, 2022
Can you try to simply remove this line?
if name == «main»:
setovi commented Nov 3, 2022
Removed, same result
Badiboy commented Nov 3, 2022
Everything is fine for me.
Footer
© 2023 GitHub, Inc.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Источник
Хелп, как исправить ошибку телеграмм бота 409 conflict на питон?
Помогите, как исправить ошибку 409 conflict
Traceback (most recent call last):
File «D:pythontelebotutil.py», line 59, in run
task(*args, **kwargs)
File «D:pythontelebot__init__.py», line 158, in __retrieve_updates
updates = self.get_updates(offset=(self.last_update_id + 1), timeout=timeout)
File «D:pythontelebot__init__.py», line 128, in get_updates
json_updates = apihelper.get_updates(self.token, offset, limit, timeout, allowed_updates)
File «D:pythontelebotapihelper.py», line 180, in get_updates
return _make_request(token, method_url, params=payload)
File «D:pythontelebotapihelper.py», line 56, in _make_request
return _check_result(method_name, result)[‘result’]
File «D:pythontelebotapihelper.py», line 75, in _check_result
raise ApiException(msg, method_name, result)
telebot.apihelper.ApiException: A request to the Telegram API was unsuccessful. The server returned HTTP 409 Conflict. Response body:
[b’<«ok»:false,»error_code»:409,»description»:»Conflict: terminated by other getUpdates request; make sure that only one bot instance is running»>‘]
»
2018-07-14 17:15:56,933 (__init__.py:299 MainThread) ERROR — TeleBot: «A request to the Telegram API was unsuccessful. The server returned HTTP 409 Conflict. Response body:
[b’<«ok»:false,»error_code»:409,»description»:»Conflict: terminated by other getUpdates request; make sure that only one bot instance is running»>‘]»
2018-07-14 17:16:00,833 (util.py:65 PollingThread) ERROR — TeleBot: «ApiException occurred, args=(‘A request to the Telegram API was unsuccessful. The server returned HTTP 409 Conflict. Response body:n[b’<«ok»:false,»error_code»:409,»description»:»Conflict: terminated by other getUpdates request; make sure that only one bot instance is running»>’]’,)
На питоне, я знаю что это означает запуск бота с двух клиентов но я запускаю только с одного, с pycharm,в чем проблема, подскажите.
P.s Скрипт бота в комменты скину если нужно !
Источник
telebot.apihelper.ApiException: A request to the Telegram API was unsuccessful. The Server returned HTTP 409 conflict #745
Comments
paritosh3006 commented Feb 13, 2020
Please answer these questions before submitting your issue. Thanks!
What version of pyTelegramBotAPI are you using?
3.6.7
What OS are you using?
Windows 10
What version of python are you using?
3.5
The text was updated successfully, but these errors were encountered:
paritosh3006 commented Feb 13, 2020
telebot.apihelper.ApiException A request to the Telegram API was
unsuccessful. The Server returned HTTP 409 conflict
Telegram API was unsuccessful. The server returned HTTP 409 Conflict.
Response body:
[b’ <«ok»:false,»error_code»:409,»description»:»Conflict:
terminated by other getUpdates request; make sure that only one bot
instance is running»>’]
ERROR — TeleBot: «A request to the Telegram API was unsuccessful.
The server returned HTTP 409 Conflict.
Response body:
[b’ <«ok»:false,»error_code»:409,»description»:»Conflict: terminated by other getUpdates
request; make sure that only one bot instance is running»>’]»
(util.py:65 Polling Thread) ERROR — TeleBot: «ApiException occurred,
args=(‘A request to the Telegram API was unsuccessful. The server returned
HTTP 409 Conflict.
Response body:
n[b’ <«ok»:false,»error_code»:409,»description»:»Conflict: terminated by other getUpdates
request; make sure that only one bot instance is running»>’]’,)
Badiboy commented Mar 1, 2020
Where is the question?
Before asking — what code are you runnung?
Footer
© 2023 GitHub, Inc.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Источник
TeleBot:A request to the Telegram API was unsuccessful #737
Comments
balzer82 commented Jan 24, 2020
Please answer these questions before submitting your issue. Thanks!
What version of pyTelegramBotAPI are you using?
pyTelegramBotAPI==3.6.7
What OS are you using?
Ubuntu 18.04.
What version of python are you using?
3.7
After some hours of running the Bot in .polling() mode, there is some issue with the Telegram API but then the Bot stops working with
Is there a way to catch this exception so the bot doesn’t stop polling?
The text was updated successfully, but these errors were encountered:
meoww-bot commented Jan 29, 2020
I use supervisor to monitor the bot process, when process exit, supervisor will restart it
rayanfer32 commented Feb 2, 2020 •
I used try except loop but still it will raise many exceptions . and bot terminates
finally resorted to my own
paritosh3006 commented Feb 11, 2020
I got this error:
telebot.apihelper.ApiException: A request to the Telegram API was unsuccessful. The Server returned HTTP 409 conflict.
meoww-bot commented Feb 12, 2020
I got this error:
telebot.apihelper.ApiException: A request to the Telegram API was unsuccessful. The Server returned HTTP 409 conflict.
the whole message is :
it because you run one more instance request to ‘getUpdates’
paritosh3006 commented Feb 12, 2020
I got this error:
telebot.apihelper.ApiException: A request to the Telegram API was unsuccessful. The Server returned HTTP 409 conflict.
the whole message is :
it because you run one more instance request to ‘getUpdates’
Please tell me how to solve this issue.
Thanks in advance
meoww-bot commented Feb 12, 2020
I got this error:
telebot.apihelper.ApiException: A request to the Telegram API was unsuccessful. The Server returned HTTP 409 conflict.
the whole message is :
it because you run one more instance request to ‘getUpdates’
Please tell me how to solve this issue.
Thanks in advance
- you run one more program instance at the same time, check the process on the server, kill one of them.
- maybe someone stole the token of your bot, chat with botfather, revoke the token, then run another instance using the new token.
paritosh3006 commented Feb 12, 2020
I got this error:
telebot.apihelper.ApiException: A request to the Telegram API was unsuccessful. The Server returned HTTP 409 conflict.
the whole message is :
it because you run one more instance request to ‘getUpdates’
Please tell me how to solve this issue.
Thanks in advance
- you run one more program instance at the same time, check the process on the server, kill one of them.
- maybe someone stole the token of your bot, chat with botfather, revoke the token, then run another instance using the new token.
I use this link to try to access to my bot: https://api.telegram.org/botToken/getUpdates:
then I got this one :
<«ok»:true,»result»:<«id»:1032572032,»is_bot»:true,»first_name»:»Rest_Bot»,»username»:»rest_chatbot»,»can_join_groups»:true,»can_read_all_group_messages»:false,»supports_inline_queries»:true>>
meoww-bot commented Feb 12, 2020
I got this error:
telebot.apihelper.ApiException: A request to the Telegram API was unsuccessful. The Server returned HTTP 409 conflict.
the whole message is :
it because you run one more instance request to ‘getUpdates’
Please tell me how to solve this issue.
Thanks in advance
- you run one more program instance at the same time, check the process on the server, kill one of them.
- maybe someone stole the token of your bot, chat with botfather, revoke the token, then run another instance using the new token.
I use this link to try to access to my bot: https://api.telegram.org/botToken/getUpdates:
then I got this one :
<«ok»:true,»result»:<«id»:1032572032,»is_bot»:true,»first_name»:»Rest_Bot»,»username»:»rest_chatbot»,»can_join_groups»:true,»can_read_all_group_messages»:false,»supports_inline_queries»:true>>
the message, looks like it works fine.
paritosh3006 commented Feb 12, 2020
I got this error:
telebot.apihelper.ApiException: A request to the Telegram API was unsuccessful. The Server returned HTTP 409 conflict.
the whole message is :
it because you run one more instance request to ‘getUpdates’
Please tell me how to solve this issue.
Thanks in advance
- you run one more program instance at the same time, check the process on the server, kill one of them.
- maybe someone stole the token of your bot, chat with botfather, revoke the token, then run another instance using the new token.
I use this link to try to access to my bot: https://api.telegram.org/botToken/getUpdates:
then I got this one :
<«ok»:true,»result»:<«id»:1032572032,»is_bot»:true,»first_name»:»Rest_Bot»,»username»:»rest_chatbot»,»can_join_groups»:true,»can_read_all_group_messages»:false,»supports_inline_queries»:true>>
the message, looks like it works fine.
Yeah, but still getting same error..
meoww-bot commented Feb 13, 2020
I got this error:
telebot.apihelper.ApiException: A request to the Telegram API was unsuccessful. The Server returned HTTP 409 conflict.
the whole message is :
it because you run one more instance request to ‘getUpdates’
Please tell me how to solve this issue.
Thanks in advance
- you run one more program instance at the same time, check the process on the server, kill one of them.
- maybe someone stole the token of your bot, chat with botfather, revoke the token, then run another instance using the new token.
I use this link to try to access to my bot: https://api.telegram.org/botToken/getUpdates:
then I got this one :
<«ok»:true,»result»:<«id»:1032572032,»is_bot»:true,»first_name»:»Rest_Bot»,»username»:»rest_chatbot»,»can_join_groups»:true,»can_read_all_group_messages»:false,»supports_inline_queries»:true>>
the message, looks like it works fine.
Yeah, but still getting same error..
That’s weird.
Are you sure you are request to ‘getUpdates’ but not ‘getMe’, ‘getMe’ won’t result to ‘409 Conflict’.
paritosh3006 commented Feb 13, 2020
I got this error:
telebot.apihelper.ApiException: A request to the Telegram API was unsuccessful. The Server returned HTTP 409 conflict.
the whole message is :
it because you run one more instance request to ‘getUpdates’
Please tell me how to solve this issue.
Thanks in advance
- you run one more program instance at the same time, check the process on the server, kill one of them.
- maybe someone stole the token of your bot, chat with botfather, revoke the token, then run another instance using the new token.
I use this link to try to access to my bot: https://api.telegram.org/botToken/getUpdates:
then I got this one :
<«ok»:true,»result»:<«id»:1032572032,»is_bot»:true,»first_name»:»Rest_Bot»,»username»:»rest_chatbot»,»can_join_groups»:true,»can_read_all_group_messages»:false,»supports_inline_queries»:true>>
the message, looks like it works fine.
Yeah, but still getting same error..
That’s weird.
Are you sure you are request to ‘getUpdates’ but not ‘getMe’, ‘getMe’ won’t result to ‘409 Conflict’.
Источник
Tiralion 0 / 0 / 0 Регистрация: 28.02.2021 Сообщений: 1 |
||||
1 |
||||
Telegram Bot 28.02.2021, 13:50. Показов 27022. Ответов 2 Метки нет (Все метки)
При написании простого бота
выползает ошибка ERROR — TeleBot: «A request to the Telegram API was unsuccessful. Error code: 409. Description: Conflict: can’t use getUpdates method while webhook is active; use deleteWebhook to delete the webhook first» что не так я делаю?
__________________
0 |
rooffall 1 / 1 / 0 Регистрация: 28.06.2020 Сообщений: 1 |
||||
25.03.2021, 23:52 |
2 |
|||
Видимо до этого пытались запустить бота не через polling, а webhook методом. Перед первом запуском кода вставьте строчку.
Позже эту строку можно будет удалить.
1 |
VetalM 1 / 1 / 0 Регистрация: 30.03.2020 Сообщений: 40 |
||||
28.03.2021, 10:33 |
3 |
|||
Попробуйте в самый конец файла добавить:
0 |
Error 409 occurred in telebot when using multiprocessing [exe file]
I want to start another process, it will start, if I write to telegram bot “start”. But right after this occurring the ERROR:
2022-04-11 11:16:13,602 (__init__.py:688 Thread-1) ERROR - TeleBot: "A request to the Telegram API was unsuccessful. Error code: 409. Description: Conflict: terminated by other getUpdates request; make sure that only one bot instance is running"
I am running ONLY one bot at the same time, already checked it. I found, that the error occurs when program trying to start a new process. Could anyone help me, please?
from time import sleep from datetime import datetime, timedelta import telebot from telebot import types from threading import Thread import multiprocessing def collecting(a): while True: print(a) sleep(3) if __name__=='__main__': bot = telebot.TeleBot(token) workers = [] def listen(): @bot.message_handler(content_types='text') def get_text(message): id = message.chat.id mes = message.text if mes=='start': bot.send_message(id, 'okey') workers.append([str(datetime.now())]) else: bot.send_message(id, mes) bot.polling() Thread(target=listen).start() while True: sleep(1) x = workers[:] for i in range(len(x)): multiprocessing.Process(target=collecting, args=(x[i],)).start() del workers[i]
UPD: Forgot to say, this error occurred only when I create exe file and run this code like exe program. This is how I create exe file:
pyinstaller --hidden-import=pkg_resources.py2_warn --onefile Program.py
Advertisement
Answer
Solved, I forgot to add this:
from multiprocessing import freeze_support
And then after if__name__=="__main__":
also need to write freeze_support()
.
3 People found this is helpful
Please answer these questions before submitting your issue. Thanks!
- What version of pyTelegramBotAPI are you using?
pyTelegramBotAPI 4.7.1
- What OS are you using?
docker images in Mac OS Ventura and Ubuntu 22.04 on Raspberry Pi 4. Same behaviour.
- What version of python are you using?
3.8-buster
3.9-bullseye
Same behaviour.
The bot runs fine but the following appears continuously in the logs. First every few seconds, some time later about 30+ seconds every exception.
2022-11-02 10:02:01,917 (init.py:1089 MainThread) ERROR — TeleBot: «Exception traceback:
Traceback (most recent call last):
File «/usr/local/lib/python3.8/site-packages/telebot/init.py», line 1077, in __threaded_polling
polling_thread.raise_exceptions()
File «/usr/local/lib/python3.8/site-packages/telebot/util.py», line 116, in raise_exceptions
raise self.exception_info
File «/usr/local/lib/python3.8/site-packages/telebot/util.py», line 98, in run
task(*args, **kwargs)
File «/usr/local/lib/python3.8/site-packages/telebot/init.py», line 653, in __retrieve_updates
updates = self.get_updates(offset=(self.last_update_id + 1),
File «/usr/local/lib/python3.8/site-packages/telebot/init.py», line 627, in get_updates
json_updates = apihelper.get_updates(self.token, offset, limit, timeout, allowed_updates, long_polling_timeout)
File «/usr/local/lib/python3.8/site-packages/telebot/apihelper.py», line 334, in get_updates
return _make_request(token, method_url, params=payload)
File «/usr/local/lib/python3.8/site-packages/telebot/apihelper.py», line 162, in _make_request
json_result = _check_result(method_name, result)
File «/usr/local/lib/python3.8/site-packages/telebot/apihelper.py», line 189, in _check_result
raise ApiTelegramException(method_name, result, result_json)
telebot.apihelper.ApiTelegramException: A request to the Telegram API was unsuccessful. Error code: 409. Description: Conflict: terminated by other getUpdates request; make sure that only one bot instance is running
Obviously no more than one instance running.
Thanks in advance