Page 1 of 1

requests.post OSError: [Errno 5] EIO

Posted: Wed Apr 05, 2017 4:44 pm
by nishizu
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) :)

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

Posted: Fri May 05, 2017 2:54 pm
by Rf3w8
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)

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

Posted: Sat May 06, 2017 10:44 am
by pfalcon
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.

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

Posted: Sat May 06, 2017 11:11 am
by Rf3w8
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.

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

Posted: Sun Oct 11, 2020 7:42 pm
by mradovan
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!

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

Posted: Thu Oct 29, 2020 12:10 pm
by bsecker
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?

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

Posted: Sat May 28, 2022 5:00 pm
by user_pico1
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.