D
D
DEUS2020-05-11 13:53:13
Python
DEUS, 2020-05-11 13:53:13

How to bypass pyTelegramBotApi blocking?

I'm trying to create my own bot.

Here is the code (primitive):

```
import telebot

TOKEN = "1281028963:AAFMmSTSnau1Q776wxpeYsDIuwWx_MDCtVo"

bot = telebot.TeleBot(TOKEN)

from telebot import apihelper

apihelper.proxy = {'https' : ' https://174.70.241.18:24404 ' }

@bot.message_handler(content_types = ['text'])
def message(message):
print(message.text)

bot.polling(none_stop = True)
```

Outputs the following:

2020-05-11 13:39:07,126 (util.py:68 PollingThread) ERROR - TeleBot: "ConnectionError occurred, args=(ProtocolError('Connection aborted.', BadStatusLine('\x00[_T\n')),)
Traceback (most recent call last):
File "C:\Users\User\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\connectionpool.py", line 667, in urlopen
self._prepare_proxy(conn)
File "C:\ Users\User\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\connectionpool.py", line 930, in _prepare_proxy
conn.connect()
File "C:\Users\User\AppData\ Local\Programs\Python\Python38-32\lib\site-packages\urllib3\connection.py", line 316, in connect
self._tunnel()
File "C:\Users\User\AppData\Local\Programs\Python\ Python38-32\lib\http\client.py", line 894, in _tunnel
(version, code, message) = response._read_status()
File "C:\Users\User\AppData\Local\Programs\Python\Python38- 32\lib\http\client.py",line 285, in _read_status
raise BadStatusLine(line)
http.client.BadStatusLine:

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\User\AppData\Local\Programs\Python\Python38-32 \lib\site-packages\requests\adapters.py", line 439, in send
resp = conn.urlopen(
File "C:\Users\User\AppData\Local\Programs\Python\Python38-32\lib\site- packages\urllib3\connectionpool.py", line 724, in urlopen
retries = retries.increment(
File "C:\Users\User\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\util \retry.py", line 403, in increment
raise six.reraise(type(error), error, _stacktrace)
File "C:\Users\User\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\packages\six.py", line 734, in reraise
raise value.with_traceback(tb)
File " C:\Users\User\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\connectionpool.py", line 667, in urlopen
self._prepare_proxy(conn)
File "C:\Users\ User\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\connectionpool.py", line 930, in _prepare_proxy
conn.connect()
File "C:\Users\User\AppData\Local\ Programs\Python\Python38-32\lib\site-packages\urllib3\connection.py", line 316, in connect
self._tunnel()
File "C:\Users\User\AppData\Local\Programs\Python\Python38- 32\lib\http\client.py",line 894, in_tunnel
(version, code, message) = response._read_status()
File "C:\Users\User\AppData\Local\Programs\Python\Python38-32\lib\http\client.py", line 285, in _read_status
raise BadStatusLine (line)
urllib3.exceptions.ProtocolError: ('Connection aborted.', BadStatusLine('\x00[_T\n'))

How to fix?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Karbivnichy, 2020-05-11
@Qpz111

Alternatively, use a working proxy:
apihelper.proxy = {'https' : '45.77.146.92:8080'}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question