requests.post OSError: [Errno 5] EIO

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
nishizu
Posts: 2
Joined: Wed Apr 05, 2017 8:42 am

requests.post OSError: [Errno 5] EIO

Post by nishizu » Wed Apr 05, 2017 4:44 pm

Hello!

I'm trying to "port" a simple script to send a notification using pushbullet from my esp8266.

Here is the original python code:

[code]
import requests
import json

body = "Corpo"
title = "Titolo"

data_send = {"type": "note", "title": title, "body": body}
API_KEY = "xxxxxxxxxxxxxxxxxxxxxxxx"

resp = requests.post('https://api.pushbullet.com/v2/pushes', data=json.dumps(data_send), headers={'Authorization': 'Bearer ' + API_KEY, 'Content-Type': 'application/json'})
[/code]

if i replace requests with urequests and i try this code on esp8266 i get this error:

[code]
ssl_handshake_status: -256
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "urequests.py", line 104, in post
File "urequests.py", line 56, in request
OSError: [Errno 5] EIO
[/code]

I'm kinda new to micropython, i hope someone could help me understand more (or just send me in the right direction) :)

Rf3w8
Posts: 14
Joined: Tue Feb 21, 2017 4:51 pm

Re: requests.post OSError: [Errno 5] EIO

Post by Rf3w8 » Fri May 05, 2017 2:54 pm

I'm experiencing the same issues more or less.
I'm trying to send a request to a Telegram Bot and what I get is

Code: Select all

ssl_handshake_status: -261
Traceback (most recent call last):
  File "main.py", line 10, in <module>
  File "urequest.py", line 28, in urlopen
OSError: [Errno 5] EIO


I'm using uRequest.py library, but I tried also with uRequests.py and having the same issue.

This is the code I'm running:

Code: Select all

bot_id = "<bot_id>"
chat_id = <chat_id>

message = "This is a message".strip().replace(" ", "%20")
content = "chat_id=" + str(chat_id) + "&text=" + message
data = urequest.urlopen("https://api.telegram.org/bot" +
                        bot_id +
                        "/sendMessage",
                        content)

pfalcon
Posts: 1155
Joined: Fri Feb 28, 2014 2:05 pm

Re: requests.post OSError: [Errno 5] EIO

Post by pfalcon » Sat May 06, 2017 10:44 am

This could be because axTLS version used currently by uPy doesn't support ciphersuites of those sites. Feel free to build the latest axTLS and use its sample client to connect. If you confirm that works, that would help to raise the priority of the upgrade.
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/

Rf3w8
Posts: 14
Joined: Tue Feb 21, 2017 4:51 pm

Re: requests.post OSError: [Errno 5] EIO

Post by Rf3w8 » Sat May 06, 2017 11:11 am

pfalcon wrote:This could be because axTLS version used currently by uPy doesn't support ciphersuites of those sites. Feel free to build the latest axTLS and use its sample client to connect. If you confirm that works, that would help to raise the priority of the upgrade.
You might be right. According to this repo, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (cyphersuite used by api.telegram.org) is not supported.
However, it looks like google.com uses the same cyphersuite, so I don't understand why it works with google and not with Telegram. Also, I'm rather sure Google uses HSTS, so a cyphersuite downgrade shouldn't be possible.

mradovan
Posts: 3
Joined: Sun Oct 11, 2020 4:32 pm

Re: requests.post OSError: [Errno 5] EIO

Post by mradovan » Sun Oct 11, 2020 7:42 pm

I have the same issue (MicroPython v1.12 on 2019-12-20; ESP8266):

import urequests as u
req = u.get("https://api.telegram.org/bot<my_token>/ ... my_chat_id>")
, i get this:

ssl_handshake_status: -40
Traceback (most recent call last):
File "", line 1, in
File "urequests.py", line 149, in get
File "urequests.py", line 93, in request
OSError: [Errno 5] EIO

But for example, this works:
req = u.get("https://telegram-webhook-sample.herokuapp.com/")

Is there any solution for this issue? Or some other possibility to send get request to the Telegram?

Tnx in advance!

bsecker
Posts: 1
Joined: Mon Sep 28, 2020 6:16 am

Re: requests.post OSError: [Errno 5] EIO

Post by bsecker » Thu Oct 29, 2020 12:10 pm

mradovan wrote:
Sun Oct 11, 2020 7:42 pm
I have the same issue (MicroPython v1.12 on 2019-12-20; ESP8266):

import urequests as u
req = u.get("https://api.telegram.org/bot<my_token>/ ... my_chat_id>")
, i get this:

ssl_handshake_status: -40
Traceback (most recent call last):
File "", line 1, in
File "urequests.py", line 149, in get
File "urequests.py", line 93, in request
OSError: [Errno 5] EIO

But for example, this works:
req = u.get("https://telegram-webhook-sample.herokuapp.com/")

Is there any solution for this issue? Or some other possibility to send get request to the Telegram?

Tnx in advance!
Just chiming in to say I have the same error as well, trying to send a post request to a slack webhook: https://hooks.slack.com/services/T00000 ... XXXXXXXXXX

Has anyone discovered a fix for this?

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

Re: requests.post OSError: [Errno 5] EIO

Post by user_pico1 » Sat May 28, 2022 5:00 pm

mradovan wrote:
Sun Oct 11, 2020 7:42 pm
I have the same issue (MicroPython v1.12 on 2019-12-20; ESP8266):

import urequests as u
req = u.get("https://api.telegram.org/bot<my_token>/ ... my_chat_id>")
, i get this:

ssl_handshake_status: -40
Traceback (most recent call last):
File "", line 1, in
File "urequests.py", line 149, in get
File "urequests.py", line 93, in request
OSError: [Errno 5] EIO

But for example, this works:
req = u.get("https://telegram-webhook-sample.herokuapp.com/")

Is there any solution for this issue? Or some other possibility to send get request to the Telegram?

Tnx in advance!
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.

Post Reply