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

TriggerFullFrameSnapshot hangs on broken connection #105

Closed
janick opened this issue Jan 10, 2019 · 4 comments
Closed

TriggerFullFrameSnapshot hangs on broken connection #105

janick opened this issue Jan 10, 2019 · 4 comments

Comments

@janick
Copy link

janick commented Jan 10, 2019

Please answer these questions before submitting your issue. Thanks!

What version of Python are you using (python -V)?

Python 2.7.10

What operating system and processor architecture are you using (python -c 'import platform; print(platform.uname());')?

('Darwin', 'Janicks-MacBook-Air.local', '18.2.0', 'Darwin Kernel Version 18.2.0: Mon Nov 12 20:24:46 PST 2018; root:xnu-4903.231.4~2/RELEASE_X86_64', 'x86_64', 'i386')

Which Python packages do you have installed (run the pip freeze or pip3 freeze command and paste output)?

altgraph==0.10.2
aniso8601==1.2.0
argcomplete==1.9.2
arlo==1.2.4
asn1crypto==0.24.0
base58==0.2.4
bdist-mpkg==0.5.0
bonjour-py==0.3
boto3==1.5.4
botocore==1.8.18
certifi==2017.11.5
cffi==1.11.2
chardet==3.0.4
click==6.7
cryptography==2.1.4
docutils==0.14
durationpy==0.5
enum34==1.1.6
Flask==0.12.1
Flask-Ask==0.9.7
future==0.16.0
futures==3.1.1
hjson==3.0.1
idna==2.6
ipaddress==1.0.19
itsdangerous==0.24
Jinja2==2.10
jmespath==0.9.3
kappa==0.6.0
lambda-packages==0.19.0
macholib==1.5.1
MarkupSafe==1.0
matplotlib==1.3.1
modulegraph==0.10.4
monotonic==1.5
numpy==1.8.0rc1
placebo==0.8.1
py2app==0.7.3
pycparser==2.18
pyobjc-core==2.5.1
pyobjc-framework-Accounts==2.5.1
pyobjc-framework-AddressBook==2.5.1
pyobjc-framework-AppleScriptKit==2.5.1
pyobjc-framework-AppleScriptObjC==2.5.1
pyobjc-framework-Automator==2.5.1
pyobjc-framework-CFNetwork==2.5.1
pyobjc-framework-Cocoa==2.5.1
pyobjc-framework-Collaboration==2.5.1
pyobjc-framework-CoreData==2.5.1
pyobjc-framework-CoreLocation==2.5.1
pyobjc-framework-CoreText==2.5.1
pyobjc-framework-DictionaryServices==2.5.1
pyobjc-framework-EventKit==2.5.1
pyobjc-framework-ExceptionHandling==2.5.1
pyobjc-framework-FSEvents==2.5.1
pyobjc-framework-InputMethodKit==2.5.1
pyobjc-framework-InstallerPlugins==2.5.1
pyobjc-framework-InstantMessage==2.5.1
pyobjc-framework-LatentSemanticMapping==2.5.1
pyobjc-framework-LaunchServices==2.5.1
pyobjc-framework-Message==2.5.1
pyobjc-framework-OpenDirectory==2.5.1
pyobjc-framework-PreferencePanes==2.5.1
pyobjc-framework-PubSub==2.5.1
pyobjc-framework-QTKit==2.5.1
pyobjc-framework-Quartz==2.5.1
pyobjc-framework-ScreenSaver==2.5.1
pyobjc-framework-ScriptingBridge==2.5.1
pyobjc-framework-SearchKit==2.5.1
pyobjc-framework-ServiceManagement==2.5.1
pyobjc-framework-Social==2.5.1
pyobjc-framework-SyncServices==2.5.1
pyobjc-framework-SystemConfiguration==2.5.1
pyobjc-framework-WebKit==2.5.1
pyOpenSSL==17.0.0
pyparsing==2.0.1
PySocks==1.6.8
python-dateutil==2.6.1
python-slugify==1.2.4
pytz==2013.7
PyYAML==3.12
requests==2.18.4
s3transfer==0.1.12
scipy==0.13.0b1
six==1.11.0
sseclient==0.0.22
toml==0.9.4
tqdm==4.19.1
Unidecode==0.4.21
urllib3==1.22
virtualenv==15.1.0
Werkzeug==0.12
xattr==0.6.4

Which Arlo hardware do you have (camera types - [Arlo, Pro, Q, etc.], basestation model, etc.)?

Alro Pro

What did you do?

I'm using one of my Arlo camera to shoot a timelapse video, using a script inspired by https://github.com/Notalifeform/arlo-timelapse-lambda. It runs fine for a while, then will eventually issue this error message and hang:

Taking snapshot...
retrieving and storing  snapshots/snapshot-20190109-165848.jpg
Waiting for 4 secs...
Taking snapshot...
retrieving and storing  snapshots/snapshot-20190109-165857.jpg
Waiting for 4 secs...
Taking snapshot...
('Connection broken: IncompleteRead(0 bytes read)', IncompleteRead(0 bytes read))

Here's the entire script:

from datetime import datetime
from datetime import timedelta
#from urllib.request import urlopen                                                                                                                   
from Arlo import Arlo
from pprint import pprint
import time
import subprocess

# Instantiating the Arlo object automatically calls Login(), which returns an oAuth token that gets cached.                                           
# Subsequent successful calls to login will update the oAuth token.                                                                                   
arlo = Arlo(userid, password)

# Get the list of devices and filter on device type to only get the basestation.                                                                      
# This will return an array which includes all of the basestation's associated metadata.                                                   
basestations = arlo.GetDevices('basestation')

# Get the list of devices and filter on device type to only get the camera.                                                                           
# This will return an array which includes all of the camera's associated metadata.                                                                   
cameras = arlo.GetDevices('camera')
#print("CAMERA: {}".format(cameras))                                                                                                                  

# Pick the camera we want                                                                                                                             
camera = None
for cam in cameras:
    if (cam['deviceName'] == 'Workbench'):
        camera = cam
        break

#                                                                                                                                                     
# Prevent MacOS from sleeping                                                                                                                         
#                                                                                                                                                     
subprocess.Popen('caffeinate')

#                                                                                                                                                     
# Keep taking snapshots until interrupted                                                                                                             
#                                                                                                                                                     
interval = timedelta(seconds=10)
while (1):
    try:
        now = datetime.now()

        # Tells the Arlo basestation to trigger a snapshot on the given camera.                                                                       
        # This snapshot is not instantaneous, so this method waits for the response and returns the url                                               
        # for the snapshot, which is stored on the Amazon AWS servers.                                                                                
        print('Taking snapshot...')
        snapshot_url = arlo.TriggerFullFrameSnapshot(basestations[0], camera)

        # This method requests the snapshot for the given url and writes the image data to the location specified.                                                                 
        # Note: Snapshots are in .jpg format.                                                                                                         
        tag = now.strftime('%Y%m%d-%H%M%S')
        filename = 'snapshots/snapshot-{}.jpg'.format(tag)

        print('retrieving and storing  {}'.format(filename))
        arlo.DownloadSnapshot(snapshot_url, filename)

        # Wait until time for next snapshot                                                                                                           
        then = now + interval;
        now = datetime.now();
        if (now < then):
            delta = then - now;
            print('Waiting for {} secs...'.format(delta.seconds))
            time.sleep(delta.seconds)

    except:
        print("Retrying....")

What did you expect to see?

I don't mind a failure. A hang, on the other hand....

What did you see instead?

A hang I can't easily recover from.

Does this issue reproduce with the latest release?

Yes.

@jeffreydwalter
Copy link
Owner

Hello, thanks for the report. This is a known issue with the Arlo API. Their system fails to return the response to the EventStream frequently.

This issue has been raised in #93 and #95

I've been slammed with other priorities, but will be committing a fix within the next few days.

@jeffreydwalter
Copy link
Owner

@janick just pushed a fix for this issue. Please give it a try when you can and let me know how it goes. Thanks!

@jeffreydwalter
Copy link
Owner

@janick did you ever get a chance to try my fix for this issue? I'd appreciate any feedback you have. Thanks.

@janick
Copy link
Author

janick commented Aug 14, 2019

I have not because I do not have a need to make another timelapse video. I appreciate the fix and will try it next time.

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

No branches or pull requests

2 participants