persandstrom / python-verisure

A python module for reading and changing status of verisure devices through verisure app api.
MIT License
138 stars 42 forks source link

Connection aborted #1

Closed lindehoff closed 8 years ago

lindehoff commented 9 years ago

First of, thank you for this script it saved me a lot of coding.

However if i call get_overview to often i get the following error:

File "../Includes/python-verisure/verisure/mypages.py", line 156, in get_overview
  File "../Includes/python-verisure/verisure/mypages.py", line 135, in _read_status
  File "/Library/Python/2.6/site-packages/requests-2.7.0-py2.6.egg/requests/sessions.py", line 477, in get
  File "/Library/Python/2.6/site-packages/requests-2.7.0-py2.6.egg/requests/sessions.py", line 465, in request
  File "/Library/Python/2.6/site-packages/requests-2.7.0-py2.6.egg/requests/sessions.py", line 573, in send
  File "/Library/Python/2.6/site-packages/requests-2.7.0-py2.6.egg/requests/adapters.py", line 415, in send
<class 'requests.exceptions.ConnectionError'>: ('Connection aborted.', BadStatusLine('',))

Is there a limit on how often you should call get_overview?

persandstrom commented 9 years ago

I have not tested how this performs in a threaded environment. As long as it is sequential there should not be any limitations on the client side. I would guess that Verisure has some kind of limit on their servers. How often are you calling get_overview?

lindehoff commented 9 years ago

Ok I also think it's on the Verisures side. I started with 10 sec for testing purposes and got the error. I now changed to 30 sec and I don't get any errors.

persandstrom commented 9 years ago

I did a test program and tried to get it to fail, but could not.

import time
from verisure import MyPages

def print_overview(overview):
    print(overview.get_typename())
    for key, value in overview.get_status():
        print('\t{}: {}'.format(key, value))

with MyPages(username, password) as verisure:
    while True:
        time.sleep(0.5)
        overviews = verisure.get_overview('alarm')
        print_overview(overviews[0])

I ran this for a few minutes. Could you post an example showing how you used the module?

lindehoff commented 8 years ago

Sorry I didn't reply sooner, I did some more testing and everything seems to work. The problem was probably on my side.