urequests - Error sending to Telegram bot

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
Frank
Posts: 1
Joined: Sat Jan 15, 2022 5:09 pm

urequests - Error sending to Telegram bot

Post by Frank » Sat Jan 15, 2022 6:21 pm

I've only recently gotten into ESPs and Micropython.
I want to send a message from ESP8266 (D1 Mini V3 NodeMCU ESP8266EX) to Telegram bot.

Code: Select all

import urequests
.
.
.
urequests.post("https://api.telegram.org/bot" + botToken + "/sendMessage?chat_id=" + str(chatId) + "&text=" + text)
Sending the message with the ESP32 is successful.
The ESP8288 comes with the following error message:

Traceback (most recent call last):
File "<stdin>", line 17, in <module>
File "urequests.py", line 120, in post
File "urequests.py", line 62, in request
OSError: -40


Is there a solution for this problem or can't I send to the bot with esp8266?

user_pico1
Posts: 4
Joined: Sat May 28, 2022 3:47 pm

Re: urequests - Error sending to Telegram bot

Post by user_pico1 » Sat May 28, 2022 3:51 pm

Frank wrote:
Sat Jan 15, 2022 6:21 pm
I've only recently gotten into ESPs and Micropython.
I want to send a message from ESP8266 (D1 Mini V3 NodeMCU ESP8266EX) to Telegram bot.

Code: Select all

import urequests
.
.
.
urequests.post("https://api.telegram.org/bot" + botToken + "/sendMessage?chat_id=" + str(chatId) + "&text=" + text)
Sending the message with the ESP32 is successful.
The ESP8288 comes with the following error message:

Traceback (most recent call last):
File "<stdin>", line 17, in <module>
File "urequests.py", line 120, in post
File "urequests.py", line 62, in request
OSError: -40


Is there a solution for this problem or can't I send to the bot with esp8266?
I have the same problem on Raspberry pi pico. Have you already solved it? Or could anyone help?
I can send requests to other sites, but it is not working with telergam.

KJM
Posts: 158
Joined: Sun Nov 18, 2018 10:53 pm
Location: Sydney AU

Re: urequests - Error sending to Telegram bot

Post by KJM » Sun May 29, 2022 12:09 am

What happens if you substitute http for https ?

user_pico1
Posts: 4
Joined: Sat May 28, 2022 3:47 pm

Re: urequests - Error sending to Telegram bot

Post by user_pico1 » Sun May 29, 2022 2:53 pm

KJM wrote:
Sun May 29, 2022 12:09 am
What happens if you substitute http for https ?
In this case error "Redirects not yet supported"
But I have no problem with sending requests on https google.

KJM
Posts: 158
Joined: Sun Nov 18, 2018 10:53 pm
Location: Sydney AU

Re: urequests - Error sending to Telegram bot

Post by KJM » Mon May 30, 2022 6:36 am

sadly urequests can't handle redirects and there is no ussl in upython for the 8286

Post Reply