urequests with ussl causes an OSError
-
On my WiPy 2.0 Board, When trying to get or post (to https links) every n amount of seconds using the urequests library it works fine and make around 10-15 successful requests then suddenly it raises an OSError -1 . And The Error points me to line 56 in the urequests source code which is:
s = ussl.wrap_socket(s, server_hostname=host)
Normally I would catch any exception that occurs and try to POST it again or POST another packet.
However, if an OSError occurs all the next Requests fails too which forces me to reset the board. -
Hello @ahmedkalnaggar,
I've been facing a similar issue with my LoPy. I've also asked in a thread.
https://forum.pycom.io/topic/2164/lopy-http-post-request-oserror
Have you solved the issue? -
@devang-sharma yes, by using gc.collect() after each request.
-
@ahmedkalnaggar Didn't work on my LoPy. Still getting the same error!
-
@devang-sharma said in urequests with ussl causes an OSError:
@ahmedkalnaggar Didn't work on my LoPy. Still getting the same error!
I might be going to face similar problems as I intend to use urequests lib to (up to now I did not come accross that problem). Therefore I am interested in the solution too.
Are you guys aware that you have to manually close the socket after each request?
See the last line of the example:
https://github.com/micropython/micropython-lib/blob/master/urequests/example_xively.pytry: import urequests as requests except ImportError: import requests r = requests.get("http://api.xively.com/") print(r) print(r.content) print(r.text) print(r.content) print(r.json()) # It's mandatory to close response objects as soon as you finished # working with them. On MicroPython platforms without full-fledged # OS, not doing so may lead to resource leaks and malfunction. r.close() -
@this-wiederkehr You've got the point. I've tried this and finally, it works without any error. Thanks a lot.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login