IpCamera: New IP Camera Binding

Error 401: HTTP 401 Unauthorized

Onvif is telling you your not authorised.

Authentication is effectively marked as show below but credentials are also configured in for the thing 001

    USERNAME="admin",
    PASSWORD="123456",
    FFMPEG_INPUT="rtsp://192.168.x.xx:554/ISAPI/Streaming/channels/401",
    ONVIF_PORT=80,
    PORT=80,

Iā€™ve also defined a second user based on the openhab raspberry installation

Your camera probably doesnt support the full onvif protocol. You have to add it to the binding as a HTTP only camera. Look in the readme.

Which is the statement that it seems not to be fully addressable via ONVIF protocol?
Mattew?


Is reported like this

I know others have had problems with onvif as well. My Reolink RCL 410 is Onvif, but doesnt work. It returns the same error you get.

1 Like

@Brignoud
Try unticking the ONVIF Authentication box to turn off Authentication and that may allow it to work. You will need to contact your camera support for help.
ONVIF can refuse to connect if the UTC time does not match between the camera and your Openhab server. You can use the ā€˜onvif device managerā€™ program to check these things.
Onvif is really only used for PTZ control so if you donā€™t need that feature, just donā€™t worry about setting it up as onvif.

1 Like

New build just uploaded with a lot of changes to all areas of the code to start getting this ready for merging.

PTZ changes for @Nanna_Agesen are included and a big thanks for the logs and testing done.

2 Likes

Just did a test with following machines, and it seems to work (so you can add them to the list) ā€¦

  • Dahua - DH-SD6CE225U-HNI
  • Dahua - DH-SD1A203T-GN-S2

Iā€™m just struggling with the PTZ and presets. Seems that I canā€™t move the camera anymore after Iā€™ve selected a preset. But guess that I first need to read bit in this topic to see what others already encountered. :wink:

Many many thanks Matthew, I got it and the problem was exactly UTC time
Also upgraded to the latest firmware
Precious advise also about PTZ that seems not work in any way with this kind of camera (SV3C) even if declared ONVIF compliant

Hi. I upgraded the OpenHAB and previously used ip camera binding stopped working, so I updated it to the version from 2020-03-11. Now snapshot from camera stopped showing and I am getting this warning:

[WARN ] [ing.ipcamera.handler.IpCameraHandler] - Camera sent 43327 bytes when the content-length header was 43326.

Any hints how to get the picture back again? Is that a new check that validates the received data?

No it has always given a much longer message when it got too much data and the warning is now a single line. The code that handles that had not changed in 16 months or more until recently when I got reports from Reolink users.

What brand of camera and also what date was the old binding created on? Just look at the file creation date.

Lastly can you post the output when you enter this into the Linux terminal? Use the snapshort url that works directly from your camera.

wget -S yourSnapshotUrlHere

It should report what the content length header was and how much got downloaded.

I am connecting to HikVision cameras. Old binding was from 2019-08-03.

When I access the camera with wget I am getting the correct picture:

[11:07:00] openhabian@openHABianPi:~$ wget -S --user=admin --ask-password http://192.168.0.206/ISAPI/Streaming/channels/101/picture
Password for user ā€˜adminā€™:
--2020-03-17 11:07:07--  http://192.168.0.206/ISAPI/Streaming/channels/101/picture
Connecting to 192.168.0.206:80... connected.
HTTP request sent, awaiting response...
  HTTP/1.1 401 Unauthorized
  Date: Tue, 17 Mar 2020 11:06:43 GMT
  Server: webserver
  X-Frame-Options: SAMEORIGIN
  Content-Length: 178
  Content-Type: text/html
  Connection: keep-alive
  Keep-Alive: timeout=10, max=99
  WWW-Authenticate: Digest qop="auth", realm="IP Camera(54477)", nonce="<cut>", stale="FALSE"
Authentication selected: Digest qop="auth", realm="IP Camera(54477)", nonce="<cut>", stale="FALSE"
Reusing existing connection to 192.168.0.206:80.
HTTP request sent, awaiting response...
  HTTP/1.1 200 OK
  Content-Type: image/jpeg; charset="UTF-8"
  Connection: close
  Content-Length:548479
Length: 548479 (536K) [image/jpeg]
Saving to: ā€˜picture.1ā€™

However the binding receives authentication error. I checked and reentered password in the configuration many times, the credentials are good, but it does not authenticate. This response repeats for any GET message sent by the binding.

2020-03-17 11:03:46.603 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - The SERVER_PORT = -1 which disables a lot of features. See readme for more info.
2020-03-17 11:03:47.605 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - About to connect to the IP Camera using the ONVIF PORT at IP:192.168.0.206:80
2020-03-17 11:03:47.613 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Sending camera: GET: http://192.168.0.206/ISAPI/Streaming/channels/101/picture
2020-03-17 11:03:47.648 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - We sucessfully connected to a ONVIF SERVICE:/onvif/device_service
2020-03-17 11:03:47.684 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - IP Camera at 192.168.0.206 is now online.
2020-03-17 11:03:47.688 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Sending camera: GET: http://192.168.0.206/ISAPI/System/Video/inputs/channels/101/motionDetection
2020-03-17 11:03:47.690 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Sending camera: GET: http://192.168.0.206/ISAPI/Streaming/channels/101/picture
2020-03-17 11:03:47.695 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Using the already open channel:0 	GET:/ISAPI/Streaming/channels/101/picture
2020-03-17 11:03:47.699 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - FieldDetection command
2020-03-17 11:03:47.706 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Sending camera: GET: http://192.168.0.206/ISAPI/Smart/FieldDetection/101
2020-03-17 11:03:47.698 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Sending camera: GET: http://192.168.0.206/ISAPI/Smart/LineDetection/101
2020-03-17 11:03:47.700 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Sending camera: GET: http://192.168.0.206/ISAPI/Smart/AudioDetection/channels/101
2020-03-17 11:03:47.732 [WARN ] [okhttp3.OkHttpClient                ] - previous digest authentication with same nonce failed, returning null
2020-03-17 11:03:47.738 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - We got an ONVIF error401:<!DOCTYPE html>
<html><head><title>Document Error: Unauthorized</title></head>
<body><h2>Access Error: 401 -- Unauthorized</h2>
<p>Authentication Error: Digest authentication information verification failed</p>
</body>
</html>

That could be caused by the UTC time not matching between the camera and openhabs server. Make sure the timezones match and the time is correct as it can matter for ONVIF. Also in the case of Hikvision make sure you turn on onvif and create a user/pass that is the same as the binding uses for the API. By default there are no users created on the camera for onvif.

Re the snapshot, Iā€™ll take a look the next few days based on your log output.

I synchronised the time and checked the timezone is the same. No change. I think the camera is configured correctly with ONVIF and user credential, as it worked fine before the upgrade. Thanks for your help, I am looking forward to root causing and fixing my issue.

@ppieczul

Did you set your camera to Basic/Digest auth?

@Nanna_Agesen thanks, it is a hint in the right direction. I have only digest authentication. When I allow basic, it starts working. So there is some issue with authentication using digest. But I donā€™t want to allow basic authentication as it gives away the credentials over the network. Thanks!

1 Like

Thanks to both of you for the info, I can reproduce it here and have it fixed already, just need time to test it before making a build.

@ppieczul
Build is now uploaded, please try it out.

Sorry for the noob question (one more)

Setting httponly protocol on SV3C camera, ā€¦ when motioncontrol channel is finally triggering?
Perheaps thereā€™s no guarantee by the bind that this will happen with the two SV3C & HTTPONLY?

I doubt "enableMotionAlarm channel, is requested to be switched on to have motionalarm ready to trigger. Iā€™m I wrong?

Sorry but documentation doesnā€™t clarify to me

Switch      Batu_CamEnableMotion "MotionAlarm on/off" { channel="ipcamera:HTTPONLY:001:enableMotionAlarm" }
Switch      Batu_CamMotionAlarm "Motion detected"   { channel="ipcamera:HTTPONLY:001:motionAlarm" }

I assume this because I never see the switch changing in my sitemap definition

        Default item=Batu_CamMotionAlarm icon=siren

Please use this thread instead for any further questions, feedback and requests to have the features added to for cropping ability which so far no one seems interested so have not bothered to add it. Seems to work fine on my cameras with the time ticking over, but for tree movement cropping is a must have IMHO.

Readme has full example for a http only camera and you are using the wrong channel for turning the motion on and off. Cameras with APIs will probably get the control added at some stage so you can use the built in motion control of the camera or use the ffmpeg one on demand. There is also a newish channel for hooking in an external PIR sensor.

https://github.com/Skinah/IpCamera#full-example

Dimmer HttpOnlyMotionControl "Motion Threshold [%d]" { channel="ipcamera:HTTPONLY:TestCam:controlMotionAlarm" }
Switch HttpOnlyMotionAlarm "Motion detected" { channel="ipcamera:HTTPONLY:TestCam:motionAlarm" }