yasharov
yasharov

Reputation: 113

How to send request with vless and vmess proxies?

I have a telegram bot and want to send messages using python requests. In my country sending request to telegram is blocked. I don't know How to config the proxy to send message to telegram. "vless" and "vmesss" proxies work fine in v2rayN windows software but they don't work in request proxies. Your help would be appreciated. I get error:

ConnectionError: HTTPSConnectionPool(host='api.telegram.org', port=443): Max retries exceeded with url:

No connection could be made because the target machine actively refused it

Here is the codes I tried:

import requests
import telebot

bot_token = 'sample_token'
proxies=dict(http='vless://[email protected]:80?path=%2FSvnTeam-TeleGram-ChaNnel-VIP%3Fed%3D2048&security=none&encryption=none&host=SvnTeamV2rayGmOne7.7.7.7.ir.Com.Site.xn--fhq0laa256bac7403eea044azr5g.CoM.&type=ws#%40expresfree%F0%9F%87%A9%F0%9F%87%AAVIP-1')
url = f"https://api.telegram.org/bot{bot_token}/getUpdates"
print(requests.get(url=url,proxies=proxies ).json())

bot = telebot.TeleBot(bot_token)
bot.send_message(chat_id='12345678', text="Hello world")

Upvotes: 0

Views: 972

Answers (1)

Sajjad Taghinezhad
Sajjad Taghinezhad

Reputation: 81

proxies=dict(http='vless://[email protected]:80?path=%2FSvnTeam-TeleGram-ChaNnel-VIP%3Fed%3D2048&security=none&encryption=none&host=SvnTeamV2rayGmOne7.7.7.7.ir.Com.Site.xn--fhq0laa256bac7403eea044azr5g.CoM.&type=ws#%40expresfree%F0%9F%87%A9%F0%9F%87%AAVIP-1')

In this line, you use another proxy protocol (VLESS) as HTTP proxy and this is incorrect usage.

'vless' is a custom protocol that used on V2ray apps and not used directly as a proxy server

You should connect to VLESS server on your v2ray client and start an HTTP proxy client on your system, then use your local HTTP proxy in your python code.

Upvotes: 0

Related Questions