Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GET request with urequests on ESP8266 results in OSError: -2 #153

Closed
stlehmann opened this issue Feb 18, 2017 · 2 comments
Closed

GET request with urequests on ESP8266 results in OSError: -2 #153

stlehmann opened this issue Feb 18, 2017 · 2 comments

Comments

@stlehmann
Copy link

I am trying to send a simple GET request to a host. Everything is fine but after the second or third request I will get an OSError: -2. The code I use is simple:

from urequests import get

>>> get('http://mrl33h.de/')
<Response object at 3fff2250>
>>> get('http://mrl33h.de/') 
<Response object at 3fff2840>
>>> get('http://mrl33h.de/')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "urequests.py", line 101, in get
  File "urequests.py", line 51, in request
OSError: -2

I can not really put my finger on what's wrong here. I'm using MicroPython v1.8.7-7-gb5a1a20a3 from 09.01.2017.

@harandK
Copy link

harandK commented Feb 18, 2017

I think you have to close the Socket. Get returns a response object, call close() with it.

@stlehmann
Copy link
Author

Ah I see. This solves the issue. Thank you for that. It is a bit confusing though because I wouldn' t expect to need to close my response object. How about using a context manager instead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants