API Problems
AnsweredRecently (last week or so), My flair program (python) is having difficulty retrieving vent and puck status from the cloud servers.
It connects, authenticates, and retrieves a few vents data (or sometimes none), and the exits after a timeout period with a requests broken connection.
This is what it looks like:
Authenticating
Authenticated for 3600s
Authentication expires in: 3599s
got data for 8 vents
Vent: Nick's Office-5384, Latest Reading: {
"Pressure": 98.62,
"RSSI": -72,
"Temperature": 21.67,
"bat_percent": "100",
"battery": 3.07,
"date": "2019-03-15T12:51:12.304906-04:00",
"online": true,
"percent_open": 1,
"set_by": "Algo"
}
Vent: Hallway-9e65, Latest Reading: {
"Pressure": 98.6,
"RSSI": -61,
"Temperature": 23.18,
"bat_percent": "100",
"battery": 3.49,
"date": "2019-03-15T12:51:19.422764-04:00",
"online": true,
"percent_open": 99,
"set_by": "Algo"
}
Vent: Family Room-7cf9, Latest Reading: {
"online": false
}
Traceback (most recent call last):
File "./vents_bridge.py", line 1197, in <module>
main()
File "./vents_bridge.py", line 1171, in main
PublishVent_data(structure, mqttc)
File "./vents_bridge.py", line 773, in PublishVent_data
sensor_readings = vent.get_rel('sensor-readings')
File "build/bdist.linux-x86_64/egg/flair_api/client.py", line 131, in get_rel
File "build/bdist.linux-x86_64/egg/flair_api/client.py", line 50, in get
File "build/bdist.linux-x86_64/egg/flair_api/client.py", line 303, in get_url
File "/usr/local/lib/python2.7/dist-packages/requests/api.py", line 72, in get
return request('get', url, params=params, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/api.py", line 58, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 508, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 658, in send
r.content
File "/usr/local/lib/python2.7/dist-packages/requests/models.py", line 823, in content
self._content = bytes().join(self.iter_content(CONTENT_CHUNK_SIZE)) or bytes()
File "/usr/local/lib/python2.7/dist-packages/requests/models.py", line 748, in generate
raise ChunkedEncodingError(e)
requests.exceptions.ChunkedEncodingError: ('Connection broken: IncompleteRead(0 bytes read)', IncompleteRead(0 bytes read))
Is something wrong with the cloud servers? I'm using the api interface from the flair github, and it's been working fine for over a year now.
-
Official comment
Thanks for the message Nick! We've been making a bunch of cloud improvements on our end and some of these improvements may have affected your API integration. If possible, could you post this issue on our GitHub page? That way we can solve issues and have them available to other users using our Python client on our GitHub.
Comment actions -
The issue is caused by flair's http servers chunking incorrectly, (see https://github.com/urllib3/urllib3/issues/1516 ), I have patched the api library (just included timeout=5.0 in their requests calls), and trapping the exception in my code. This seems to be working for now, but the root cause is the flair http server not chunking correctly.
If anyone needs it, the fixes are here: https://github.com/NickWaterton
I have submitted a pull request.
Please sign in to leave a comment.
Comments
3 comments