L
L
Leo2020-04-23 13:59:25
Python
Leo, 2020-04-23 13:59:25

How to fix error 10061 when connecting a telegram bot to a proxy?

Hello, I'm trying to connect a bot to a proxy to bypass the blocking, but it gives an error:

requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionRefusedError(10061, 'Подключение не установлено, т.к. конечный компьютер отверг запрос на подключение', None, 10061, None))

I tried with TOR proxy and private paid proxy, but the result is higher error. I tried to connect through a proxy in telegram - everything works, but it does not work in the bot ... I tried to write socks5h instead of socks5 - nothing changed.
The code:
import telebot
from telebot import types, apihelper

apihelper.proxy = {'https:':'socks5://логин:пароль@IP:порт'}
bot = telebot.TeleBot('Верный токен')

bot.polling(none_stop=True)


pytelegrambotapi 3.6.7, requests 2.7.0, urllib3 1.25.9, gunicorn 20.0.4, telebot 0.0.3
Windows 10
What could be possible solutions to this problem?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
soremix, 2020-04-23
@lopphopp

Updated requests, urllib3, gunicorn, PySocks Instead
of :socks5socks5h

telebot.apihelper.proxy = {'https':'socks5h://127.0.0.1:9050'}

Now everything is ok

N
Nikolay, 2020-04-23
@SODINNER

Install pysocks: pip install pysocks
Socks5 only work if pysocks is installed. A common problem, I myself encountered it when users ran the script and complained that it did not work with proxies.
=)
UPD: Maybe there are other libraries that work with socks5 and without additional packages, but it is for requests proxy that you need to install pysocks.

D
Dimonchik, 2020-04-23
@dimonchik2013

that is, from your computer, ILV does not block to the cart through the proxy, but does it block to the proxy?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question