Black Lives Matter - Action and Equality. ... Adafruit is part of the Stop Hate for Profit campaign. Adafruit is open and shipping.
0

Python SSLError when sending feed data
Moderators: adafruit_support_bill, adafruit

Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
Please be positive and constructive with your questions and comments.

Python SSLError when sending feed data

by doubletap on Sat Feb 06, 2016 11:01 am

I created a small python script which takes the output of speedtest-cli (Speedtest.net) and sends the values to my io.adafruit feeds using the REST-API. It was working and sent a dozen or so sets of values and the just stopped with an "requests.exceptions.SSLError." I had made no changes to the code and have triple checked everything on both ends and can find no reason for it. I even regenerated a new key incase it was some sort of key issue. The error is generated on the first 'aio.send' call.
See Attached file for full error message.
Python 2.7.9
Raspbian Jessie (build 4.1.13-v7+ #826)

Screen Shot 2016-02-06 at 6.48.30 AM.png
Screen Shot 2016-02-06 at 6.48.30 AM.png (110.8 KiB) Viewed 307 times


At this point the only thing I can think of is it's an issue on the server side of things. Any help on this would be greatly appreciated.

~Mike

doubletap
 
Posts: 11
Joined: Wed Sep 11, 2013 11:23 pm

Re: Python SSLError when sending feed data

by adafruit2 on Mon Feb 08, 2016 6:44 pm

does it work now? you may have to try: catch errors and retry connecting

adafruit2
Site Admin
 
Posts: 19223
Joined: Fri Mar 11, 2005 7:36 pm

Re: Python SSLError when sending feed data

by doubletap on Mon Feb 08, 2016 6:56 pm

It started working later on that evening of the my post to here. It Ran all of yesterday without issue but had stopped working earlier this morning returning the same SSLError message. Currently it is back up and running again.
I have changed my python code to catch IOError's as this is what the SSLError falls under. You mentioned reconnecting, is there a Python API function which will allow me to disconnect from the io server once the code runs or is this disconnect handled after each send?

doubletap
 
Posts: 11
Joined: Wed Sep 11, 2013 11:23 pm

Re: Python SSLError when sending feed data

by tdicola on Mon Feb 08, 2016 9:19 pm

Yep the requests library that the REST API client uses should automatically disconnect after making a call, and then connect again when another send call is made. One other thing to try if you haven't already are the steps here to install the requests library with better SSL support: https://github.com/adafruit/io-client-p ... i-ssl-note This might help resolve SSL warnings and issues. Like you said though it could be a transient server side glitch. Catching the IOError and retrying later like you mention is a smart thing to do in general. If you get an IOError I would have it pause for a bit (perhaps another minute, etc.) and try uploading again.

tdicola
 
Posts: 1074
Joined: Thu Oct 17, 2013 9:11 pm

Please be positive and constructive with your questions and comments.