Start telebot_proxy in python and Connection error

Viewed 93

I got an error when trying to connect to Telegram and Python with the following proxy

Code

import os
import requests
import socket
import socks
import telebot
from telebot import apihelper
from telebot import types
import urllib3
   
TOKEN = "87-----------------------ewCp10yzTJhQ"
ip='192.111.139.165' #your proxy's ip
port = 4145 #your proxy's port
socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, ip, port)
socket.socket = socks.socksocket 
    
url = 'http://ip.42.pl/raw'
print(requests.get(url).text)
bot = telebot.TeleBot(TOKEN)
url = 'http://ip.42.pl/raw'
print(requests.get(url).text)
    
@bot.message_handler(content_types=['text'])
def botmain(user):
    usertext = user.text
    userchatid = user.chat.id
    ipp = "http://ip.42.pl/raw"
    print(usertext)
    print(str(ipp))
    print(requests.get(ipp).text)


bot.polling(True)

Note: The proxy is now safe and has been checked

Error Message

C:\Users\rashi\AppData\Local\Programs\Python\Python38-32\lib\site-packages\requests\adapters.py", line 514, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='api.telegram.org', port=443): Max retries exceeded with url: /bot87--70:AAGv------------------wCp10yzTJhQ/getUpdates?offset=1&timeout=20 (Caused by SSLError(SSLCertVerificationError(1, ``'[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1125)')))

Can someone help me identify the where the connection is? Also, what is the reason for not connecting to the proxy? (Maybe the location of my code is wrong, but I am not sure.)

0 Answers
Related