quatanium / python-onvif

ONVIF Client Implementation in Python
MIT License
470 stars 319 forks source link

ONVIFError: Unknown error: <urlopen error [Errno 113] No route to host> #72

Closed zqingxi closed 5 years ago

zqingxi commented 5 years ago

Hello Guys, I get this error when I am trying to run the GetProfiles funtion:

Traceback (most recent call last):

  File "<ipython-input-11-46373cee5b14>", line 1, in <module>
    media_profile = media.GetProfiles()[0]

  File "/usr/local/lib/python2.7/dist-packages/onvif-0.2.0-py2.7.egg/onvif/client.py", line 32, in wrapped
    raise ONVIFError(err)

ONVIFError: Unknown error: <urlopen error [Errno 113] No route to host>

I am using python2.7, the code is :

from onvif import ONVIFCamera
mycam = ONVIFCamera('192.168.0.112', 80, 'admin', '12345')
media = mycam.create_media_service()
ptz = mycam.create_ptz_service()
media_profile = media.GetProfiles()[0];

Any help will be appreciated, thanks.

ssieb commented 5 years ago

That most likely means that the camera isn't at that address.

zqingxi commented 5 years ago

That most likely means that the camera isn't at that address.

Thank you very much. The problem is solved. It is the network problem. After run following command:

from onvif import ONVIFCamera
mycam = ONVIFCamera('192.168.0.112', 80, 'admin', '12345')
mycam.devicemgmt.GetHostname()

the output is:

(HostnameInformation){
   FromDHCP = False
   Name = "Hikvision"
 }

so the address is correct. Then run :

media = mycam.create_media_service()
ptz = mycam.create_ptz_service()
media_profile = media.GetProfiles()[0]

it output :

Traceback (most recent call last):

  File "<ipython-input-7-46373cee5b14>", line 1, in <module>
    media_profile = media.GetProfiles()[0]

  File "/usr/local/lib/python2.7/dist-packages/onvif-0.2.0-py2.7.egg/onvif/client.py", line 32, in wrapped
    raise ONVIFError(err)

ONVIFError: Unknown error: <urlopen error timed out>

then I put the camera and my computer in the same router, run the code once again (PS: change the IP and port ), no error, it succeed. Thanks @ssieb