Thanks for your contributions, it is excellent work.
I am having issues getting my camera to work in sitemaps. It is a sannce (generic) IP cam supporting onvif (but I also tried to set it up as http only with the same result). The cam gives status as online, but it also logs an HTTP error in the log, after it connects.
Error from the log (there seems to be a semicolon at the end of the GET):
2018-05-30 20:34:34.245 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Trying to connect with new request for camera at IP:192.168.0.32
2018-05-30 20:34:34.319 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - + The request is going to be GET:/snapshot.cgi?user=admin&pwd=pass:
2018-05-30 20:34:34.376 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpResponse(decodeResult: failure(java.lang.IllegalArgumentException: a header name cannot contain the following prohibited characters: =,;: \t\r\n\v\f: ,), version: HTTP/1.1)
2018-05-30 23:59:03.715 [DEBUG] [org.openhab.binding.ipcamera ] - BundleEvent [unknown:512] - org.openhab.binding.ipcamera
2018-05-30 23:59:03.810 [DEBUG] [org.openhab.binding.ipcamera ] - ServiceEvent REGISTERED - {org.eclipse.smarthome.core.thing.binding.ThingHandlerFactory}={component.name=org.openha$
2018-05-30 23:59:03.818 [DEBUG] [org.openhab.binding.ipcamera ] - BundleEvent STARTING - org.openhab.binding.ipcamera
2018-05-30 23:59:03.822 [DEBUG] [org.openhab.binding.ipcamera ] - BundleEvent STARTED - org.openhab.binding.ipcamera
2018-05-30 23:59:40.279 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Getting configuration to initialize a new IP Camera at IP 192.168.0.32
2018-05-30 23:59:40.292 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - About to connect to the IP Camera using the ONVIF PORT at IP:192.168.0.32:10554
2018-05-30 23:59:41.574 [ERROR] [ing.ipcamera.handler.IpCameraHandler] - The camera connection had a SOAP error, this may indicate your camera does not fully support ONVIF, check for an up$
2018-05-30 23:59:41.702 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Trying to connect with new request for camera at IP:192.168.0.32
2018-05-30 23:59:43.533 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - + The request is going to be GET:/snapshot.cgi?user=admin&pwd=pwd:
2018-05-30 23:59:44.215 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpResponse(decodeResult: failure(java.lang.IllegalArgumentException: a header name cannot contain the foll$
HTTP/1.1 200 OK
Server: GoaHead
2018-05-30 23:59:44.277 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Trying to connect with new request for camera at IP:192.168.0.32
2018-05-30 23:59:44.383 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - + The request is going to be GET:/snapshot.cgi?user=admin&pwd=pwd:
2018-05-30 23:59:44.514 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpResponse(decodeResult: failure(java.lang.IllegalArgumentException: a header name cannot contain the foll$
HTTP/1.1 200 OK
Server: GoaHead
with http thing:
2018-05-31 00:03:41.444 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Getting configuration to initialize a new IP Camera at IP 192.168.0.32
2018-05-31 00:03:41.471 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Camera at 192.168.0.32 has a snapshot address of:http://192.168.0.32:13439/snapshot.cgi?user=admin&pwd=pwd:
2018-05-31 00:03:41.475 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Trying to connect with new request for camera at IP:192.168.0.32
2018-05-31 00:03:41.506 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - + The request is going to be GET:/snapshot.cgi?user=admin&pwd=pwd:
2018-05-31 00:03:41.539 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpResponse(decodeResult: failure(java.lang.IllegalArgumentException: a header name cannot contain the foll$
HTTP/1.1 200 OK
Server: GoaHead
@toroid
I’ll take a look to see if I can work around that when a camera replies with null instead of a valid location. I can probably get it going but you will need to move all 3 controls to then get an accurate location from the camera so a rule on openhab startup to specify a XYZ location would be a good idea.
@frutak
The illegal characters are in the header of the reply back from the camera. You could confirm this with the Linux tool ‘tcpdump’. The : in the request is not there, it is my way of showing where the url starts and stops in the logs so I can see if carriage returns and the like are entered in by users in the snapshot override field. The best way forward would be to use tcpdump to confirm if it is the camera or not so if it is a bug in the netty library we can report it. I think it will be the camera so check for a newer firmware.
@TomBeerten
Your camera is not giving a content length on how large the picture is and this is causing the issue. I may be able to work around this camera issue by guessing how much ram is needed but I would need to err on the larger side and it would place more ram requirements on your server. Maybe 500kb per picture I could guess at. At the least I will detect and put something in the logs that this is happening so thanks for the log.
@frutak
Does your password contain one of the illegal characters? Your camera uses the password in the url string and this goes into the headers so that may be the cause. A space may not be allowed, so try a password that is less complex with no spaces and see if it solves the issue.
2018-05-31 03:15:38.291 [ome.event.ItemCommandEvent] - Item 'ONVIFGenericIPCameraWithONVIFSupport_Pan' received command 48
==> /var/log/openhab2/openhab.log <==
2018-05-31 03:15:38.300 [ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method 'ThingHandler.handleCommand()' on 'org.openhab.binding.ipcamera.handler.IpCameraHandler@10f8329': null
java.lang.NullPointerException: null
at org.openhab.binding.ipcamera.handler.IpCameraHandler.setAbsolutePan(IpCameraHandler.java:927) [80:org.openhab.binding.ipcamera:2.3.0.201805252336]
at org.openhab.binding.ipcamera.handler.IpCameraHandler.handleCommand(IpCameraHandler.java:878) [80:org.openhab.binding.ipcamera:2.3.0.201805252336]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:?]
at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:153) [106:org.eclipse.smarthome.core:0.10.0.oh230]
at org.eclipse.smarthome.core.internal.common.InvocationHandlerSync.invoke(InvocationHandlerSync.java:59) [106:org.eclipse.smarthome.core:0.10.0.oh230]
at com.sun.proxy.$Proxy180.handleCommand(Unknown Source) [80:org.openhab.binding.ipcamera:2.3.0.201805252336]
at org.eclipse.smarthome.core.thing.internal.profiles.ProfileCallbackImpl.handleCommand(ProfileCallbackImpl.java:75) [113:org.eclipse.smarthome.core.thing:0.10.0.oh230]
at org.eclipse.smarthome.core.thing.internal.profiles.SystemDefaultProfile.onCommandFromItem(SystemDefaultProfile.java:49) [113:org.eclipse.smarthome.core.thing:0.10.0.oh230]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:?]
at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:153) [106:org.eclipse.smarthome.core:0.10.0.oh230]
at org.eclipse.smarthome.core.internal.common.Invocation.call(Invocation.java:53) [106:org.eclipse.smarthome.core:0.10.0.oh230]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]
at java.lang.Thread.run(Thread.java:748) [?:?]
Now supports images from cameras that dont specify a content-length header. @TomBeerten and @Yura_Qenf can you test this build please as both of you are the only ones to report this issue. Note: cameras that do this need to keep their snapshots below 512kbytes in size or an error will get thrown.
PTZ fix for cameras that reply with null when asked what their current position is. @nakh_Home and @toroid can you test as you both reported this.
Instar major bug fix.
Dahua possibly now has motion alarm features. Big THANKS to @psyciknz for the help with this.
Do u have all three controls linked? Pan tilt and zoom are they all linked and able to be moved in paper ui? Also did you test absolute movement in onvif device manager as there are three types of movement with onvif.
2018-05-31 22:40:08.788 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - About to connect to the IP Camera using the ONVIF PORT at IP:192.168.192.85:80
2018-05-31 22:40:24.425 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - Fetching the number of Media Profile this camera supports.
2018-05-31 22:40:35.827 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - Checking the selected Media Profile is a valid number.
2018-05-31 22:40:35.832 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - Fetching a Token for the selected Media Profile.
2018-05-31 22:40:35.834 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - Auto fetching the snapshot URL for the selected Media Profile.
2018-05-31 22:40:44.964 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - About to interrogate the camera to see if it supports PTZ.
2018-05-31 22:40:58.513 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - Camera is reporting that it does NOT support Absolute PTZ controls via ONVIF
2018-05-31 22:40:58.517 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - Finished with PTZ, now fetching the Video URL's the camera supports.
2018-05-31 22:41:20.231 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - Camera at 192.168.192.85:80 is not closing the connection quick enough.
2018-05-31 22:41:20.261 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - Camera at 192.168.192.85:80 is not closing the connection quick enough.
2018-05-31 22:41:25.212 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - Camera at 192.168.192.85:80 is not closing the connection quick enough.
2018-05-31 22:41:25.237 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - Camera at 192.168.192.85:80 is not closing the connection quick enough.
2018-05-31 22:41:30.199 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - Camera at 192.168.192.85:80 is not closing the connection quick enough.
2018-05-31 22:41:30.219 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - Camera at 192.168.192.85:80 is not closing the connection quick enough.
2018-05-31 22:41:40.195 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - Camera at 192.168.192.85:80 is not closing the connection quick enough.
2018-05-31 22:41:40.203 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - Camera at 192.168.192.85:80 is not closing the connection quick enough.
Fixed bug that was only in last build that would update the image channel twice.
Added more logging and some changes to PTZ to help narrow down where problems lie. Need debug output from logs if you have trouble.
Increased time to wait for slow cameras or slow networks from 4 seconds to 10.
@tnemrap
Try this latest build, also please make sure you have the " Enable Hikvision-CGI" box ticked which is found on the same page as enabling ONVIF. I now own 3 HIKVISION cameras which are working for me after ticking that box. Also these cameras are far slower to respond to requests for a snapshot and if your network is busy with traffic it may have caused issues
Still some errors in log it is on GB Lan but it is constantly recording to Surveillance Station so it can be a performance issue with the camera.
2018-06-01 20:51:40.205 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - Camera at 192.168.192.85:80 is not closing the connection quick enough.
2018-06-01 20:51:40.206 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - Camera at 192.168.192.85:80 is not closing the connection quick enough.
2018-06-01 20:51:53.515 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - Camera at 192.168.192.85:80 is not closing the connection quick enough.
2018-06-01 20:51:53.515 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - Camera at 192.168.192.85:80 is not closing the connection quick enough.
2018-06-01 20:55:15.706 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - Camera at 192.168.192.85:80 is not closing the connection quick enough.
2018-06-01 20:55:15.706 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - Camera at 192.168.192.85:80 is not closing the connection quick enough.
2018-06-01 21:03:15.385 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - Camera at 192.168.192.85:80 is not closing the connection quick enough.
2018-06-01 21:03:15.385 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - Camera at 192.168.192.85:80 is not closing the connection quick enough.
Backend code now operates for the first time with full Async (can do multiple requests at the same time). Let me know if older releases work when this one does not, as well as your camera brand and some debug log output.
HIKVISION has a heap of changes to make the alarms detect faster and more reliable. @ArsalanAlli you were wanting faster detection, give it a try.
Some camera brands now allow NVR channel to be selected, needs more work done as people give feedback.
Improved online/offline detection when multiple cameras are setup.
Some cameras now default to having a snapshot url entered by default so they connect faster.
@tnemrap Now I have had a chance to do some testing with my new hik cameras I have found the resolution and compression settings determine how fast you can get a picture from the camera. Mine at 4k needs at least 3 seconds to transfer the snapshot and that is on a fast network with no other traffic.
2018-06-03 21:36:01.250 [ERROR] [ing.ipcamera.handler.IpCameraHandler] - Can not connect to the camera at 192.168.1.40:80 check your network for issues.
2018-06-03 21:36:05.935 [ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method 'ThingHandler.handleCommand()' on 'org.openhab.binding.ipcamera.handler.IpCameraHandler@1aa61c': null
at org.openhab.binding.ipcamera.handler.IpCameraHandler.setAbsolutePan(IpCameraHandler.java:1033) [80:org.openhab.binding.ipcamera:2.3.0.201806011247]
at org.openhab.binding.ipcamera.handler.IpCameraHandler.handleCommand(IpCameraHandler.java:981) [80:org.openhab.binding.ipcamera:2.3.0.201806011247]
2018-06-03 21:36:07.082 [ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method 'ThingHandler.handleCommand()' on 'org.openhab.binding.ipcamera.handler.IpCameraHandler@1aa61c': null
at org.openhab.binding.ipcamera.handler.IpCameraHandler.setAbsolutePan(IpCameraHandler.java:1033) [80:org.openhab.binding.ipcamera:2.3.0.201806011247]
at org.openhab.binding.ipcamera.handler.IpCameraHandler.handleCommand(IpCameraHandler.java:981) [80:org.openhab.binding.ipcamera:2.3.0.201806011247]
2018-06-03 21:36:11.254 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - About to connect to the IP Camera using the ONVIF PORT at IP:192.168.1.40:80
2018-06-03 21:36:17.768 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - Fetching the number of Media Profile this camera supports.
2018-06-03 21:36:22.025 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - Checking the selected Media Profile is a valid number.
2018-06-03 21:36:22.028 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - Fetching a Token for the selected Media Profile.
2018-06-03 21:36:22.030 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - About to interrogate the camera to see if it supports PTZ.
2018-06-03 21:36:52.583 [ERROR] [ing.ipcamera.handler.IpCameraHandler] - NPE occured when trying to connect to the camera with ONVIF
2018-06-03 21:44:55.003 [ERROR] [ing.ipcamera.handler.IpCameraHandler] - Can not connect to the camera at 192.168.1.40:80 check your network for issues.
2018-06-04 10:57:08.518 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Getting configuration to initialize a new IP Camera at IP 192.168.1.40
2018-06-04 10:57:08.523 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - About to connect to the IP Camera using the ONVIF PORT at IP:192.168.1.40:80
2018-06-04 10:57:16.560 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - Fetching the number of Media Profile this camera supports.
2018-06-04 10:57:19.559 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - Checking the selected Media Profile is a valid number.
2018-06-04 10:57:19.561 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - Fetching a Token for the selected Media Profile.
2018-06-04 10:57:19.564 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - Auto fetching the snapshot URL for the selected Media Profile.
2018-06-04 10:57:22.487 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - About to fetch some information about the Media Profiles from the camera
2018-06-04 10:57:22.490 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - ********************* Media Profile 0 details reported by camera at IP:192.168.1.40 *********************
2018-06-04 10:57:22.492 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Camera will use this Media Profile unless you change it in the binding by pressing on the pencil icon in PaperUI.
2018-06-04 10:57:22.494 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Media Profile 0 is named:VideoEncoder_1
2018-06-04 10:57:22.496 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Media Profile 0 uses video encoder :H_264
2018-06-04 10:57:22.498 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Media Profile 0 uses video quality :10.0
2018-06-04 10:57:22.500 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Media Profile 0 uses video resoltion :1280 x 720
2018-06-04 10:57:22.502 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Media Profile 0 uses video bitrate :0
2018-06-04 10:57:22.505 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - ********************* Media Profile 1 details reported by camera at IP:192.168.1.40 *********************
2018-06-04 10:57:22.507 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Media Profile 1 is named:VideoEncoder_2
2018-06-04 10:57:22.509 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Media Profile 1 uses video encoder :H_264
2018-06-04 10:57:22.512 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Media Profile 1 uses video quality :10.0
2018-06-04 10:57:22.514 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Media Profile 1 uses video resoltion :640 x 320
2018-06-04 10:57:22.517 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Media Profile 1 uses video bitrate :0
2018-06-04 10:57:22.519 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - About to interrogate the camera to see if it supports PTZ.
2018-06-04 10:57:33.201 [ERROR] [ing.ipcamera.handler.IpCameraHandler] - NPE occured when trying to connect to the camera with ONVIF
2018-06-04 10:57:33.532 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Connecting to camera at IP:192.168.1.40 with request GET:/onvif/snapshot
2018-06-04 10:57:33.912 [DEBUG] [ipcamera.internal.MyNettyAuthHandler] - ++++++++ Auth Handler created ++++++++ /onvif/snapshot
2018-06-04 10:57:33.926 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - ++++++++ Handler 1 created ++++++++ :/onvif/snapshot
2018-06-04 10:57:34.039 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - New request has been sent to camera.
2018-06-04 10:57:34.063 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Connection to camera is closed. GET:/onvif/snapshot
2018-06-04 10:57:34.068 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - ------- Closing Handler, leaving 0 handlers alive ------- :/onvif/snapshot
getting a loop of “New request has been sent to camera.”