IpCamera: New IP Camera Binding

Although, my camera only has RTSP streams. I can access the streams using http://, but that is only using internet explorer with a surveilance client plugin

Just wanted to wish everyone a Merry Christmas and a thank you for making the binding so popular. This thread is now the third most read for the past 12 months!

https://community.openhab.org/top/yearly?order=views

Last night I upgraded Openhab to 2.4.0 Stable and it appears everything is still working in this binding, but it is too early to be sure. Please backups your systems before doing any upgrades as that is just good practice.

1 Like

And thank you to for making this great binding, and a Merry Christmas to you as well.

Hm not working here. Am I clicking on the right URL? I tried it with pcmus.com from the first post

Works for me both times I checked, maybe this is why they r updating the openhab servers as it may be a browser issueā€¦

Anyway the link is this

pcmus.com/openhab/IpCameraBinding/

The click on the file to download. Still have issues try another browser like chrome.

1 Like

@matt1 Thank you and merry Christmas.

I still seem to have the same issue with the binding when running under the final 2.4 release. I restarted the server just after midnight yesterday. And the image stopped updating about 5 hours after that. Motion event doesnā€™t trigger either. And here is the log:

2018-12-19 05:04:42.878 [ERROR] [ing.ipcamera.handler.IpCameraHandler] - Can not connect with HTTP to the camera at 192.168.0.46:80 check your network for issues.
2018-12-19 05:05:36.883 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - About to connect to the IP Camera using the ONVIF PORT at IP:192.168.0.46:80
2018-12-19 05:05:50.416 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - Camera is reporting that it does NOT support Absolute PTZ controls via ONVIF
2018-12-19 05:05:50.419 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - Finished with PTZ with no errors, now fetching the Video URL for RTSP from the camera.
2018-12-19 05:05:57.749 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - Cleaning the channels has just force closed a connection.
2018-12-19 05:06:06.767 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - Can't find ch when removing handler        URL:null
2018-12-19 05:06:06.768 [ERROR] [ing.ipcamera.handler.IpCameraHandler] - Can not connect with HTTP to the camera at 192.168.0.46:80 check your network for issues.
2018-12-19 05:06:06.773 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - Cleaning the channels has just force closed a connection.
2018-12-19 05:06:06.785 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - Can't find ch when removing handler        URL:/cgi-bin/eventManager.cgi?action=attach&codes=[All]
2018-12-19 05:07:00.776 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - About to connect to the IP Camera using the ONVIF PORT at IP:192.168.0.46:80
2018-12-19 05:07:11.640 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - Camera is reporting that it does NOT support Absolute PTZ controls via ONVIF
2018-12-19 05:07:11.642 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - Finished with PTZ with no errors, now fetching the Video URL for RTSP from the camera.
2018-12-19 05:07:23.411 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - Cleaning the channels has just force closed a connection.
2018-12-19 05:07:28.443 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - Can't find ch when removing handler        URL:null
2018-12-19 05:07:28.445 [ERROR] [ing.ipcamera.handler.IpCameraHandler] - Can not connect with HTTP to the camera at 192.168.0.46:80 check your network for issues.
2018-12-19 05:07:29.085 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - Can't find ch when removing handler        URL:/cgi-bin/snapshot.cgi?channel=0
2018-12-19 05:08:22.451 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - About to connect to the IP Camera using the ONVIF PORT at IP:192.168.0.46:80
2018-12-19 05:10:33.008 [ERROR] [l.internal.messaging.saaj.client.p2p] - SAAJ0009: Message send failed
2018-12-19 05:10:33.015 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - SOAP error when trying to connect with ONVIF. This may indicate your camera does not fully support ONVIF, check for an updated firmware for your camera. Will try and connect with HTTP. Camera at IP:192.168.0.46, fault was com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Message send failed
2018-12-19 05:10:34.039 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - Cleaning the channels has just force closed a connection.
2018-12-19 05:10:34.107 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - Can't find ch when removing handler        URL:/cgi-bin/snapshot.cgi?channel=0
2018-12-19 05:10:39.034 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - Cleaning the channels has just force closed a connection.
2018-12-19 05:10:44.127 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - Can't find ch when removing handler        URL:null
2018-12-19 05:10:44.128 [ERROR] [ing.ipcamera.handler.IpCameraHandler] - Can not connect with HTTP to the camera at 192.168.0.46:80 check your network for issues.
2018-12-19 05:10:45.089 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - Can't find ch when removing handler        URL:/cgi-bin/snapshot.cgi?channel=0
2018-12-19 05:11:38.134 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - About to connect to the IP Camera using the ONVIF PORT at IP:192.168.0.46:80
2018-12-19 05:11:43.140 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - Can not connect with ONVIF to the camera at 192.168.0.46, check the ONVIF_PORT is correct. Fault was java.net.ConnectException: Host not available.
2018-12-19 05:11:54.166 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - Cleaning the channels has just force closed a connection.
2018-12-19 05:11:59.215 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - Can't find ch when removing handler        URL:null
2018-12-19 05:11:59.216 [ERROR] [ing.ipcamera.handler.IpCameraHandler] - Can not connect with HTTP to the camera at 192.168.0.46:80 check your network for issues.
2018-12-19 05:12:00.100 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - Can't find ch when removing handler        URL:/cgi-bin/snapshot.cgi?channel=0
2018-12-19 05:12:53.235 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - About to connect to the IP Camera using the ONVIF PORT at IP:192.168.0.46:80
2018-12-19 05:13:06.130 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - Camera is reporting that it does NOT support Absolute PTZ controls via ONVIF
2018-12-19 05:13:06.133 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - Finished with PTZ with no errors, now fetching the Video URL for RTSP from the camera.
2018-12-19 05:13:18.238 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - Cleaning the channels has just force closed a connection.
2018-12-19 05:13:23.281 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - Can't find ch when removing handler        URL:null
2018-12-19 05:13:23.287 [ERROR] [ing.ipcamera.handler.IpCameraHandler] - Can not connect with HTTP to the camera at 192.168.0.46:80 check your network for issues.
2018-12-19 05:14:17.303 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - About to connect to the IP Camera using the ONVIF PORT at IP:192.168.0.46:80
2018-12-19 05:14:26.580 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - Camera is reporting that it does NOT support Absolute PTZ controls via ONVIF
2018-12-19 05:14:26.582 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - Finished with PTZ with no errors, now fetching the Video URL for RTSP from the camera.

The imageā€™s timestamp is 05:13:13, coincide the with the last log entries.

Does the code have some kind of back-off algorithm to continue trying?

Thanks,

It is possible your problem is not easy to solve so please create a new thread and mention my name in the new thread so I get notified.

My first gut feeling is the camera may have crashed as the log shows it is behaving differently and not consistant, try turning the camera off and back on, does that bring the camera back online? I really need TRACE level log output, see the readme at github as it explains how to enable this. Also if possible I need the log output BEFORE the first problem, and then into where you are having the issue as sometimes a problem only occurs once and then it throws the system out of wack. At least some trace level when the problem is occuring may give clues.

How are you watching the feed? what app or UI is being used? Do you leave the picture open all the time? Java version being used? Camera brand and model? When did it start happening, did you change something recently or are you a new user of the binding?

More info is needed especially the trace level log output and please post it in a new thread.

Matt1ā€¦ people like you, with so much dedication to help the community, are the ones that deserve our respect and gratitude. Thanks and enjoy a wonderful Christmas time.

2 Likes

Matt1ā€¦ I am struggling to make this popular onvif camera work within openhab (http://www.vstarcam.com/C7824WIP-HD-indoor-IP-Camera-138.html).

I have installed your ip camera binding with the following camera definitions:

.things file:
Thing ipcamera:ONVIF:001 [ IPADDRESS="172.26.0.61", PASSWORD="xxx", USERNAME="yyy", SNAPSHOT_URL_OVERIDE="http://172.26.0.61:81/snapshot.cgi?user=xxx&pwd=yyy", ONVIF_PORT=80, PORT=81]
(I also tried without ā€œuser=xxx&pwd=yyyā€)

.items file
Image VStarCamImage { channel="ipcamera:ONVIF:001:image" }

.sitemap file
Image url="http://google.com/leaveLinkAsThis" item=VStarCamImage refresh=5000

However using your ipcamerabinding the following lines fill the log file continuosly:

01:56:10.427 [DEBUG] [ding.ipcamera.handler.IpCameraHandler] - Channel marked as closing, channel:0 URL:/snapshot.cgi?user=xxx&pwd=yyy
01:56:10.430 [DEBUG] [ding.ipcamera.handler.IpCameraHandler] - commonCameraHandler closed channel:0 URL:/snapshot.cgi?user=xxx&pwd=yyy
01:56:10.431 [DEBUG] [ding.ipcamera.handler.IpCameraHandler] - Closing CommonCameraHandler. URL:/snapshot.cgi?user=xxx&pwd=yyy
01:56:14.853 [DEBUG] [ding.ipcamera.handler.IpCameraHandler] - Sending camera at IP:172.26.0.61, URL:/snapshot.cgi?user=xxx&pwd=yyy
01:56:14.856 [DEBUG] [ding.ipcamera.handler.IpCameraHandler] - CommonCameraHandler created.... 1 channels tracked (some of these may be closed).
01:56:14.861 [TRACE] [.ipcamera.internal.MyNettyAuthHandler] - MyNettyAuthHandler is now setup for GET:/snapshot.cgi?user=xxx&pwd=yyy
01:56:14.862 [DEBUG] [ding.ipcamera.handler.IpCameraHandler] - Have re-opened the closed channel:0 GET:/snapshot.cgi?user=xxx&pwd=yyy
01:56:15.474 [DEBUG] [ding.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)
HTTP/1.1 200 OK
Server: GoaHead

Then I have tried to use an item image defined as

Image url="http://172.26.0.61:81/snapshot.cgi?user=xxxx&pwd=xxxxx&res=1" refresh=5000

And then my log file is continuously filled with many lines like these ones:

20:33:08.338 [WARN ] [org.eclipse.jetty.http.HttpParser    ] - Illegal character 0x20 in state=HEADER_IN_NAME for buffer DirectByteBuffer@693b54[p=39,l=131,c=16384,r=92]={HTTP/1.1 200 OK\r\n... GoaHead\r\nTue, <<<12 Jun 2012 01:56...ection: close\n\n>>>\xFf\xD8\xFf\xE0\x00\x10JFIF\x00\x01\x01\x00\x00\x01\x00...\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00}
20:33:08.657 [WARN ] [org.eclipse.jetty.http.HttpParser    ] - bad HTTP parsed: 400 Illegal character 0x20 for HttpReceiverOverHTTP@1ab97ee(rsp=HEADER,failure=null)[HttpParser{s=HEADER_IN_NAME,0 of 0}]
20:33:09.475 [WARN ] [org.eclipse.jetty.http.HttpParser    ] - Illegal character 0x20 in state=HEADER_IN_NAME for buffer DirectByteBuffer@693b54[p=39,l=131,c=16384,r=92]={HTTP/1.1 200 OK\r\n... GoaHead\r\nTue, <<<12 Jun 2012 01:56...ection: close\n\n>>>\xFf\xD8\xFf\xE0\x00\x10JFIF\x00\x01\x01\x00\x00\x01\x00...\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00}
20:33:09.795 [WARN ] [org.eclipse.jetty.http.HttpParser    ] - bad HTTP parsed: 400 Illegal character 0x20 for HttpReceiverOverHTTP@1877fa4(rsp=HEADER,failure=null)[HttpParser{s=HEADER_IN_NAME,0 of 0}]
20:33:10.658 [WARN ] [org.eclipse.jetty.http.HttpParser    ] - Illegal character 0x20 in state=HEADER_IN_NAME for buffer DirectByteBuffer@693b54[p=39,l=8819,c=16384,r=8780]={HTTP/1.1 200 OK\r\n... GoaHead\r\nTue, <<<12 Jun 2012 01:56...S\xA8\xD3sVw1b\x83h\x1c\x1e*\xEc\x1f>>>93\xCb<\x80\xFa\xE6\xE6c_\xC1>\xE7-u...\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00}
20:33:10.953 [WARN ] [org.eclipse.jetty.http.HttpParser    ] - bad HTTP parsed: 400 Illegal character 0x20 for HttpReceiverOverHTTP@5a7e14(rsp=HEADER,failure=null)[HttpParser{s=HEADER_IN_NAME,0 of 0}]
20:33:11.626 [WARN ] [org.eclipse.jetty.http.HttpParser    ] - Illegal character 0x20 in state=HEADER_IN_NAME for buffer DirectByteBuffer@693b54[p=39,l=4475,c=16384,r=4436]={HTTP/1.1 200 OK\r\n... GoaHead\r\nTue, <<<12 Jun 2012 01:56...\x1e\x80\xE3\xDa\xBeM\xFf\x00\x82|^\xC9\xE2o\x0e>>>\xAf]\xD4~&\xCf\xF0\xDbR\xF1W\x86\xF5\xFb\xA7uM...\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00}
20:33:11.934 [WARN ] [org.eclipse.jetty.http.HttpParser    ] - bad HTTP parsed: 400 Illegal character 0x20 for HttpReceiverOverHTTP@c7532c(rsp=HEADER,failure=null)[HttpParser{s=HEADER_IN_NAME,0 of 0}]
20:33:12.605 [WARN ] [org.eclipse.jetty.http.HttpParser    ] - Illegal character 0x20 in state=HEADER_IN_NAME for buffer DirectByteBuffer@693b54[p=39,l=131,c=16384,r=92]={HTTP/1.1 200 OK\r\n... GoaHead\r\nTue, <<<12 Jun 2012 01:56...ection: close\n\n>>>\xFf\xD8\xFf\xE0\x00\x10JFIF\x00\x01\x01\x00\x00\x01\x00...\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00}
.....................................
.....................................

With my limited programming knowledge I have concluded that the camera is reporting not only the current image (as we would expect) but also a precedent html header.

I have researched in the CGI programming guide for this camera (VStarCam, C Series CGI Guide (programming guide).pdf (316.1 KB)) but I have not found any alternative to fix this issue. Soā€¦Iā€™m stuck.

I get the camera image displayed on the web browser with the following command:
http://172.26.0.61:81/snapshot.cgi?user=xxx&pwd=yyy

Stream video can also be seen in the web broser with
http://172.26.0.61:81/videostream.cgi?user=xxx&pwd=yyy
and in VLC with
rtsp://xxx:yyy@172.26.0.61:10554/udp/av0_0

In openHAB and with the help of the http binding, an h264 stream is also displayed in the web browser and in the mobile app with the following item in the sitemap:
Webview url="http://172.26.0.61:81/videostream.cgi?user=xxx&pwd=yyy" height=11

Video is displayed while on the intranet but not outside as the camera does not support mjepg. Hence being able to display the camera image every x seconds is a must.

My question isā€¦ Will you be so kind to have a look at it and, if possible, implement a fix within your binding?
Thanks a lot in advance.

Your problem looks like one that has been found previously here

I suspect it is the date header being in wrong format and is causing the netty library to complain. Can u contact them to find out if there is a way to ignore the header? See this link as it has been asked before.

It is most likely a bug in your cameras firmware.

Edit: that Api you linked looks great, it is likely we can get alarms working with that camera easily if this issue is solved.

Hi Matt,

Yesterday I increased the POLL_CAMERA_MS value to 30,000 (it was 5000) and it was alright for the whole night. I will continue to observe the behavior, and will open a new thread if the issue shows up. I do notice the camera light once in a while switches from green to red, and couple of seconds later switches back to green. So it either lost connection to WIFI or crashed as you mentioned. Itā€™s an Amcrest camera. When the binding freezes, I can still view the stream in the Amcrest app on the Android phone.

In any case, Iā€™ve resumed the work with the rule to try to send the REFRESH command, and I notice that the image wasnā€™t refreshed. Hereā€™s the code I have:

def sendSnapshot(event):                                                                                                                                      
    itemName = 'CamImage'                                                       
    attachmentUrls = []                                                         
                                                                                
    previousBytes = []                                                          
    for idx in range(5):                                                        
        logger.info('**** h0 {}'.format(idx))                                   
        itemRegistry.getItem(itemName).send(RefreshType.REFRESH)                
                                                                                
        time.sleep(5)                                                           
                                                                                
        image = items[itemName].getBytes()                                      
        if image != previousBytes:                                              
            fileName = '{}/{}-{}.jpg'.format(_SNAPSHOT_PATH, 'CamImage', idx)   
            file = io.open(fileName, 'wb')                                      
            file.write(image)                                                   
            file.close()                                                        
                                                                               
            attachmentUrls.append('file://' + fileName)                                                                                                        
            previousBytes = image                                               
                                                                                
    logger.info('Sending camera snapshot with {} images'.format(                
                len(attachmentUrls)))                                           
    Mail.sendMail(emailAddress, 'Cam image', '', attachmentUrls)         

I attempted to fetch new images 5 times, but the images are all the same on coincide with the last update o the Image item.

The log doesnā€™t indicate that the binding is retrieving the image outside the configured polling interval 90 secs in the .thing file. Am I using REFRESH correctly?

Thanks,

2018-12-20 22:58:36.302 [INFO ] [eclipse.smarthome.model.script.Rules] - **** h0 0
2018-12-20 22:58:38.796 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpContent(data: PooledSlicedByteBuf(ridx: 0, widx: 496, cap: 496/496, unwrapped: PooledUnsafeDirectByteBuf(ridx: 496, widx: 496, cap: 496)), decoderResult: success)
2018-12-20 22:58:38.799 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Camera has sent some kind of message.Bytes=0
2018-12-20 22:58:38.802 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - HTTP Result back from camera is    :-- myboundary^M
Content-Type: text/plain^M                                                      
Content-Length:41^M                                                             
Code=VideoMotionInfo;action=State;index=0^M                                     
^M                                                                              
-- myboundary^M                                                                 
Content-Type: text/plain^M                                                      
Content-Length:41^M                                                             
Code=VideoMotionInfo;action=State;index=0^M                                     
^M                                                                              
-- myboundary^M                                                                 
Content-Type: text/plain^M                                                      
Content-Length:33^M                                                             
Code=NewFile;action=Pulse;index=0^M                                             
^M                                                                              
-- myboundary^M                                                                 
Content-Type: text/plain^M                                                      
Content-Length:33^M                                                             
Code=NewFile;action=Pulse;index=0^M                                             
^M                                                                              
-- myboundary^M                                                                 
Content-Type: text/plain^M                                                      
Content-Length:41^M                                                             
Code=VideoMotionInfo;action=Stat:                                               
2018-12-20 22:58:38.805 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpContent(data: PooledSlicedByteBuf(ridx: 0, widx: 530, cap: 530/530, unwrapped: PooledUnsafeDirectByteBuf(ridx: 530, widx: 530, cap: 4096)), decoderResult: success)
- myboundary^M                                                                 
Content-Type: text/plain^M                                                      
Content-Length:41^M                                                             
Code=VideoMotionInfo;action=State;index=0^M                                     
^M                                                                              
-- myboundary^M                                                                 
Content-Type: text/plain^M                                                      
Content-Length:41^M                                                             
Code=VideoMotionInfo;action=State;index=0^M                                     
^M                                                                              
-- myboundary^M                                                                 
Content-Type: text/plain^M                                                      
Content-Length:41^M                                                             
Code=VideoMotionInfo;action=State;index=0^M                                     
^M                                                                              
-- myboundary^M                                                                 
Content-Type: text/plain^M                                                      
Content-Length:41^M                                                             
Code=VideoMotionInfo;action=State;index=0^M                                     
^M                                                                              
-- myboundary^M                                                                 
Content-Type: text/plain^M                                                      
Content-Length:33^M                                                             
Code=NewFile;action=Pulse;index=0^M                                             
^M                                                                              
:                                                                               
2018-12-20 22:58:41.484 [INFO ] [eclipse.smarthome.model.script.Rules] - **** h0 1
2018-12-20 22:58:42.335 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpContent(data: PooledSlicedByteBuf(ridx: 0, widx: 100, cap: 100/100, unwrapped: PooledUnsafeDirectByteBuf(ridx: 100, widx: 100, cap: 4096)), decoderResult: success)
2018-12-20 22:58:42.338 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Camera has sent some kind of message.Bytes=0
2018-12-20 22:58:42.342 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - HTTP Result back from camera is    :-- myboundary^M
Content-Type: text/plain^M                                                      
Content-Length:36^M                                          
                                                                                                     4099,1      
:                                                                               
2018-12-20 22:58:45.211 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpContent(data: PooledSlicedByteBuf(ridx: 0, widx: 105, cap: 105/105, unwrapped: PooledUnsafeDirectByteBuf(ridx: 105, widx: 105, cap: 4096)), decoderResult: success)
2018-12-20 22:58:45.214 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Camera has sent some kind of message.Bytes=0
2018-12-20 22:58:45.218 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - HTTP Result back from camera is    :-- myboundary^M
Content-Type: text/plain^M                                                      
Content-Length:41^M                                                             
Code=VideoMotionInfo;action=State;index=0^M                                     
^M                                                                              
:                                                                               
2018-12-20 22:58:45.310 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpContent(data: PooledSlicedByteBuf(ridx: 0, widx: 101, cap: 101/101, unwrapped: PooledUnsafeDirectByteBuf(ridx: 101, widx: 101, cap: 2048)), decoderResult: success)
2018-12-20 22:58:45.315 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Camera has sent some kind of message.Bytes=0
2018-12-20 22:58:45.319 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - HTTP Result back from camera is    :-- myboundary^M
Content-Type: text/plain^M                                                      
Content-Length:37^M                                                             
Code=VideoMotion;action=Start;index=0^M                                         
^M                                                                              
:                                                                               
2018-12-20 22:58:45.513 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpContent(data: PooledSlicedByteBuf(ridx: 0, widx: 105, cap: 105/105, unwrapped: PooledUnsafeDirectByteBuf(ridx: 105, widx: 105, cap: 2048)), decoderResult: success)
2018-12-20 22:58:45.515 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Camera has sent some kind of message.Bytes=0
2018-12-20 22:58:45.516 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - HTTP Result back from camera is    :-- myboundary^M
Content-Type: text/plain^M                                                      
Content-Length:41^M                                                             
Code=VideoMotionInfo;action=State;index=0^M                           
:                                                                               
2018-12-20 22:58:45.842 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpContent(data: PooledSlicedByteBuf(ridx: 0, widx: 97, cap: 97/97, unwrapped: PooledUnsafeDirectByteBuf(ridx: 97, widx: 97, cap: 1024)), decoderResult: success)
2018-12-20 22:58:45.844 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Camera has sent some kind of message.Bytes=0
2018-12-20 22:58:45.845 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - HTTP Result back from camera is    :-- myboundary^M
Content-Type: text/plain^M                                                      
Content-Length:33^M                                                             
Code=NewFile;action=Pulse;index=0^M                                             
^M                                                                              
:                                                                               
2018-12-20 22:58:45.919 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpContent(data: PooledSlicedByteBuf(ridx: 0, widx: 105, cap: 105/105, unwrapped: PooledUnsafeDirectByteBuf(ridx: 105, widx: 105, cap: 512)), decoderResult: success)
2018-12-20 22:58:45.920 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Camera has sent some kind of message.Bytes=0
2018-12-20 22:58:45.922 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - HTTP Result back from camera is    :-- myboundary^M
Content-Type: text/plain^M                                                      
Content-Length:41^M                                                             
Code=VideoMotionInfo;action=State;index=0^M                                     
^M                                                                              
:                                                                               
2018-12-20 22:58:46.122 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpContent(data: PooledSlicedByteBuf(ridx: 0, widx: 105, cap: 105/105, unwrapped: PooledUnsafeDirectByteBuf(ridx: 105, widx: 105, cap: 512)), decoderResult: success)
2018-12-20 22:58:46.123 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Camera has sent some kind of message.Bytes=0
2018-12-20 22:58:46.125 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - HTTP Result back from camera is    :-- myboundary^M
Content-Type: text/plain^M                                                      
Content-Length:41^M                                                             
Code=VideoMotionInfo;action=State;index=0^M                                  
:                                                                               
2018-12-20 22:58:46.324 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpContent(data: PooledSlicedByteBuf(ridx: 0, widx: 105, cap: 105/105, unwrapped: PooledUnsafeDirectByteBuf(ridx: 105, widx: 105, cap: 496)), decoderResult: success)
2018-12-20 22:58:46.326 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Camera has sent some kind of message.Bytes=0
2018-12-20 22:58:46.330 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - HTTP Result back from camera is    :-- myboundary^M
Content-Type: text/plain^M                                                      
Content-Length:41^M                                                             
Code=VideoMotionInfo;action=State;index=0^M                                     
^M                                                                              
:                                                                               
2018-12-20 22:58:46.526 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpContent(data: PooledSlicedByteBuf(ridx: 0, widx: 105, cap: 105/105, unwrapped: PooledUnsafeDirectByteBuf(ridx: 105, widx: 105, cap: 496)), decoderResult: success)
2018-12-20 22:58:46.529 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Camera has sent some kind of message.Bytes=0
2018-12-20 22:58:46.532 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - HTTP Result back from camera is    :-- myboundary^M
Content-Type: text/plain^M                                                      
Content-Length:41^M                                                             
Code=VideoMotionInfo;action=State;index=0^M                                     
^M                                                                              
:                                                                               
2018-12-20 22:58:46.727 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpContent(data: PooledSlicedByteBuf(ridx: 0, widx: 105, cap: 105/105, unwrapped: PooledUnsafeDirectByteBuf(ridx: 105, widx: 105, cap: 480)), decoderResult: success)
2018-12-20 22:58:46.729 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Camera has sent some kind of message.Bytes=0
2018-12-20 22:58:46.731 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - HTTP Result back from camera is    :-- myboundary^M
Content-Type: text/plain^M                                                      
Content-Length:41^M                                                             
Code=VideoMotionInfo;action=State;index=0^M                                     
^M                                                                              
:                                                                    
2018-12-20 22:58:46.864 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpContent(data: PooledSlicedByteBuf(ridx: 0, widx: 97, cap: 97/97, unwrapped: PooledUnsafeDirectByteBuf(ridx: 97, widx: 97, cap: 480)), decoderResult: success)
2018-12-20 22:58:46.866 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Camera has sent some kind of message.Bytes=0
2018-12-20 22:58:46.867 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - HTTP Result back from camera is    :-- myboundary^M
Content-Type: text/plain^M                                                      
Content-Length:33^M                                                             
Code=NewFile;action=Pulse;index=0^M                                             
^M                                                                              
:                                                                               
2018-12-20 22:58:47.277 [INFO ] [eclipse.smarthome.model.script.Rules] - **** h0 2
2018-12-20 22:58:47.844 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpContent(data: PooledSlicedByteBuf(ridx: 0, widx: 97, cap: 97/97, unwrapped: PooledUnsafeDirectByteBuf(ridx: 97, widx: 97, cap: 464)), decoderResult: success)
2018-12-20 22:58:47.845 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Camera has sent some kind of message.Bytes=0
2018-12-20 22:58:47.847 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - HTTP Result back from camera is    :-- myboundary^M
Content-Type: text/plain^M                                                      
Content-Length:33^M                                                             
Code=NewFile;action=Pulse;index=0^M                                             
^M                                                                              
:                                                                               
2018-12-20 22:58:53.927 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpContent(data: PooledSlicedByteBuf(ridx: 0, widx: 100, cap: 100/100, unwrapped: PooledUnsafeDirectByteBuf(ridx: 100, widx: 100, cap: 464)), decoderResult: success)
2018-12-20 22:58:53.930 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Camera has sent some kind of message.Bytes=0
2018-12-20 22:58:53.934 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - HTTP Result back from camera is    :-- myboundary^M
Content-Type: text/plain^M                                                      
Content-Length:36^M                                                             
Code=VideoMotion;action=Stop;index=0^M                                          
2018-12-20 22:58:54.663 [INFO ] [eclipse.smarthome.model.script.Rules] - **** h0 3
2018-12-20 22:59:01.839 [INFO ] [eclipse.smarthome.model.script.Rules] - **** h0 4
2018-12-20 22:59:08.466 [INFO ] [eclipse.smarthome.model.script.Rules] - Sending camera snapshot with 1 images

Sorry I made a mistake the refresh command is not implemented for image. There is a channel called updateImageNow if you change it to on or off it will fetch a new picture. Moving it either direction will cause a new image to be fetched.

matt1, yes I saw that as well. I will give it a try tonight. Thank you.

Hi Matt1, thanks for your quick answer.

I suspect it is the date header being in wrong format and is causing the netty library to complain.

You are right, itā€™s a bug in the camera. I have found this post on HA (C7824WIP PTZ camera) where the solution applied has been to change the snapshot.cgi script to send proper HTTP headers ( Date: 2 Jun 2012 01:56:34 GMT instead of Tue, 12 Jun 2012 01:56:34 GMT). But my cam has a new firmware and I canā€™t get into it to try apply the same mod.

Can u contact them to find out if there is a way to ignore the header? See this link as it has been asked before.

Iā€™d very much like but I donā€™t even know what netty is and after having had a look at their place in githubā€¦ I donā€™t even understand anything at all about what I read :frowning: ā€¦ Maybe some day in a near futureā€¦I still have a lot to learn :slight_smile:

Nevertheless after some research I have also found another alternative: to use nginx as a reverse proxy. I know nothing about it either but it seems to be easier to implement.

that Api you linked looks great, it is likely we can get alarms working with that camera easily if this issue is solved.

Yes, itā€™s quite easy to implement those cgi commands within openhab with the help of the http binding. In fact I already have tested some of them through items and they work as expected.
Thanks!

Iā€™m having difficulty getting an image to appear in the control section of the Paper UI or in Habpanel. Iā€™ve installed the binding and I can get the camera to show that itā€™s online, but still canā€™t get an image to appear.

The camera Iā€™m using is labelled as a Lorex LNC204, however, Iā€™ve discovered that itā€™s actually a Starvedia camera, model UM-IC717HD. I actually have four of them.

http://www.starvedia.com/download/UM-IC717HD-EN.pdf

It streams video and audio (MPEG4 video + G.711 audio) using RTSP, with the following link;

rtsp://ip_cam_address/CAM_ID.password

I can get it work with VLC player, but itā€™s my understanding that there is no way at the moment to embed the rtsp stream.

The camera also has a snapshot URL; http://ip_address/snapshot.cgi, which works from my browser, but I canā€™t get it to work with the OH binding. Iā€™ve tried several of the options; ONVIF, HTTP, HIKVISION, but none of them seem to work with the snapshot option. Iā€™ve tried over-riding the IP address, by entering the URL above, but still nothing.

image

image

Anything else I can try?

Thanks

@matvegaSW

I believe it can be fixed but it would mean I need a camera and at least 8 hours to create a new special handler in the netty pipeline to filter out the bad http header. I am sure you understand I am not going to do this when I donā€™t get paid. It is cheaper for you to buy a camera that works already, you then get a more secure camera with better night vision and picture quality.

@Toopy14

See the Readme file on what to do if you have problems, hint TRACE.

Hi Toopy,

As Matt1 recommends in his first post, you should enable TRACE to get an understanding on whatā€™s wrong. Just type this once you have started the Karaf console:

log:set TRACE org.openhab.binding.ipcamera

I have seen the specs of your camera and it seems quite similar to mines (there are many Chinese cameras sold under different brand/appearance but based on same hardw/softw). Our cameras both use the same command to retrieve the image. To the best of my knowledge, the camera responds with information containing some headers plus the image. One or several of those headers is incorrect, not in accordance with standards, and quite often it is the date header to blame (as I have also read in some other sites related to Domoticz and Home Assistant). If your issue is also any of the headers and I can find a way to fix it, I will share the solution here.

Thanks Matt1, I fully understand. Iā€™m pretty sure that you have already spent too much time in developing the ip camera binding and I donā€™t want you to spend 8 hours just trying to find a solution to this issue. I have also spent a lot of time but I have learnt a lot during the process and this is what motivates me to continue searching for a solution. Eventually, one way or another I will benefit from your work and others because of what I have learnt along this long thread. So, again, thanks and have a wonderful Christmas time :wink:

Hereā€™s the debug information Iā€™m getting.

20:58:26.373 [DEBUG] [ding.ipcamera.handler.IpCameraHandler] - Sending camera at IP:192.168.2.13,       URL:192.168.2.13/snapshot.cgi
20:58:26.400 [DEBUG] [ding.ipcamera.handler.IpCameraHandler] - CommonCameraHandler created.... 1 channels tracked (some of these may be closed).
20:58:26.467 [TRACE] [.ipcamera.internal.MyNettyAuthHandler] - MyNettyAuthHandler is now setup for      GET:192.168.2.13/snapshot.cgi
20:58:26.468 [DEBUG] [ding.ipcamera.handler.IpCameraHandler] - Have re-opened  the closed channel:0     GET:192.168.2.13/snapshot.cgi
20:58:26.484 [DEBUG] [ding.ipcamera.handler.IpCameraHandler] - DefaultHttpResponse(decodeResult: success, version: HTTP/1.1)
HTTP/1.1 400 Bad Request
Server: mini_httpd/1.19 19dec2003
Date: Sat, 22 Dec 2018 20:58:26 GMT
Cache-Control: no-cache,no-store
Content-Type: text/html; charset=%s
Connection: close
20:58:26.489 [DEBUG] [ding.ipcamera.handler.IpCameraHandler] - Channel marked as closing, channel:0     URL:192.168.2.13/snapshot.cgi
20:58:26.491 [DEBUG] [ding.ipcamera.handler.IpCameraHandler] - DefaultHttpContent(data: PooledSlicedByteBuf(ridx: 0, widx: 282, cap: 282/282, unwrapped: PooledUnsafeDirectByteBuf(ridx: 472, widx: 472, cap: 1024)), decoderResult: success)
20:58:26.495 [DEBUG] [ding.ipcamera.handler.IpCameraHandler] - Camera has sent some kind of message.Bytes=0
20:58:26.498 [DEBUG] [ding.ipcamera.handler.IpCameraHandler] - EmptyLastHttpContent
20:58:26.499 [DEBUG] [ding.ipcamera.handler.IpCameraHandler] - Camera has sent some kind of message.Bytes=282
20:58:26.501 [DEBUG] [ding.ipcamera.handler.IpCameraHandler] - Camera has sent last part of the message.Bytes=282
20:58:26.503 [DEBUG] [ding.ipcamera.handler.IpCameraHandler] - HTTP Result back from camera is  :<HTML>
<HEAD><TITLE>400 Bad Request</TITLE></HEAD>
<BODY BGCOLOR="#cc9999" TEXT="#000000" LINK="#2020ff" VLINK="#4040cc">
<H4>400 Bad Request</H4>
Bad filename.
<HR>
<ADDRESS><A HREF="http://www.acme.com/software/mini_httpd/">mini_httpd/1.19 19dec2003</A></ADDRESS>
</BODY>
</HTML>
:
20:58:26.506 [DEBUG] [ding.ipcamera.handler.IpCameraHandler] - commonCameraHandler closed channel:0     URL:192.168.2.13/snapshot.cgi
20:58:26.507 [DEBUG] [ding.ipcamera.handler.IpCameraHandler] - Closing CommonCameraHandler.             URL:192.168.2.13/snapshot.cgi

That shows everything is fine, your camera is saying the URL is a bad request.
So try another one from this link and then ask your camera support for how to get a working URL.

http://www.ispyconnect.com/man.aspx?n=Lorex