Snapshotting from my cameras (UPDATE: added live URL for your assistance)

So, I’ve got an Aposonic DVR that serves up a file at:
http://192.168.1.100:8000/cgi-bin/wappaint?camera_no=1&name=[name]&password=[pass]&pic_size=2
(Any time brackets appear, it is just to mask my data - I’ve put the correct username, password, etc. in there.)
When I visit that URL, IE prompts me to download the file of “Unknown File Type” ‘wappaint’. I download it, add the .jpg extension to the filename and I can open the image.

When I set it up in Vera, I get the dreaded red X instead of seeing my camera image. I’ve been doing lots of searching for solutions, but can’t get it to work. My guess is that the camera system is serving up a file without an extension… but other people have reported successfully using camera URLs that don’t contain a ‘.jpg’ extension.

Vera Lite (UI5)
Manual option to set up the camera
Manuall set the device_file to D_DigitalSecurityCamera1.xml
URL set to cgi-bin/wappaint?camera_no=1&animation=0&name=[name]&password=[pass]&pic_size=2
IP set to 192.168.1.100:8000

Any ideas are much appreciated!

—UPDATE—
Silly as this might be, I’d really love some help… so I’ve created a ‘tester’ account with limited access to view one of my cameras. This way, anyone who would like to help can work with my live data in their own Vera. (And anyone curious can use the link to download a picture of my front yard…)
http://ip.winninghamfamily.com:8000/cgi-bin/wappaint?camera_no=1&animation=0&name=tester&password=1234&pic_size=2

Hello James

Out of interest, I had a go at this. I’m guessing your in southern Texas? Any way I found that the Vera encodes the URLs plugged into it but your video server doesn’t seem to like the URL once encoded. So this:

http://ip.winninghamfamily.com:8000/cgi-bin/wappaint?camera_no=1&animation=0&name=tester&password=1234&pic_size=2

is encoded correctly as this by Vera (see HTML URL Encoding Reference):

http://ip.winninghamfamily.com:8000/cgi-bin%2Fwappaint%3Fcamera_no%3D1%26animation%3D0%26name%3Dtester%26password%3D1234%26pic_size%3D2

Resulting in:

"404 Not Found
The requested URL /cgi-bin/wappaint?camera_no=1&animation=0&name=tester&password=1234&pic_size=2 was not found on this server. "

Change the encoding to put back in the slash and the question mark like so:

http://ip.winninghamfamily.com:8000/cgi-bin/wappaint?camera_no%3D1%26animation%3D0%26name%3Dtester%26password%3D1234%26pic_size%3D2

You get an “improvement”:

“502 Bad Gateway
The CGI was not CGI/1.1 compliant.”

Change all the encoding back to normal, except the equal sign after password and it still doesn’t work - replace that with an equals sign and it then works again:

http://ip.winninghamfamily.com:8000/cgi-bin/wappaint?camera_no=1&animation=0&name=tester&password%3D1234&pic_size=2

I’m pretty surprised about this as it seems unlikely this would occur - so maybe I’m missing something somewhere - perhaps someone else would like to comment. Regardless I would be having a chat to the DVR people about what their take on it is - sounds like a bug in their server. Or check for recent DVR firmware updates.

There are rules about how to encode a URL. What does and what does NOT get encoded is important.

Browsers know how to do this … many people do not do this correctly …

You do NOT encode anything before the first ?
After that you have things of the form Name1=Value1&Name2=Value2&…
You must encode the names and the values as appropriate … but not the = separating the names from the values or the & separating the name/value pairs (unless they are part of the name or the value!).

Thanks for the great analysis - I see what you guys are talking about.

I updated to the most recent firmware and it had an interesting effect inasmuch as now, when I visit the URL to directly access an image… it displays the image in the browser, rather than prompting me to download a file of Unknown File Type with no extension.

Still, when I right-click the red X in the Vera camera setup wizard and click properties, I see the embedded source URL is fully decoded - and that URL generates a 404 error, and a partially coded URL gives 502 error (just as before, and documented in a-lurker’s post).

So, am I getting this right… Vera is susceptible to my DVR’s shortcomings, which my browser is able to work around?

  1. I will likely contact Aposonic about this - it seems they are at least somewhat aware since a recent firmware update had an effect on the way it serves those images.
    [size=11pt]2) I have updated the firmware, so any helpful troubleshooting anyone has done may be worth another shot now. ;D[/size]

Again, big thanks for your continued help - getting these cameras to work is the missing piece for me to have all of my stuff working through Vera!

Richard has this correct - I now believe it’s a Vera problem, not a DVR problem.

Refer to http://www.rfc-editor.org/rfc/rfc1738.txt: The characters “;”, “/”, “?”, “:”, “@”, “=” and “&” are the characters which may be reserved for special meaning within a scheme. No other characters may be reserved within a scheme.

Effectively I’m misleading you as I’m effectively blaming the wrong end - sorry it’s been a long day. However yes the URLs are incorrect but that’s the whole point.

When you create a new camera device and enter the URLs these are severely fiddled with by Vera - as follows:

U15–>Add Devices–>I want to add an IP Camera–>Add then Manually Add
Then “Or, if your camera is not on the list, paste the URL which returns a JPG file in the box below:” So past in the full URL
http://ip.winninghamfamily.com:8000/cgi-bin/wappaint?camera_no=1&animation=0&name=tester&password=1234&pic_size=2

Then a page is shown where it says “What type of camera is it?” If you select say “Generic IP camera” it drastically alters the URL to a totally none useable form. Leave it unselected, which counter intuitive for a start.

Likewise entering a Username and Password is a waste of time as they are already part of the URL previously entered.
For a second time it shows “Or, if your camera is not on the list, paste the URL which returns a JPG file in the box below:”
So just operate the Next button.

As soon as you do so in Firefox, you will see the following in the console. It outputs a debug message saying what it is about to do; then checks the domain and then tries to get the image.

Debug message:
[16:30:20.523] 2013-02-18 05:30:20: camera_check_command: http://Vera_IP/port_3480/data_request?id=lu_wget&url=http://ip.winninghamfamily.com:8000 camera url: http://Vera_IP/port_3480/data_request?id=lu_wget&url=http://ip.winninghamfamily.com:8000/cgi-bin%2Fwappaint%3Fcamera_no%3D1%26animation%3D0%26name%3Dtester%26password%3D1234%26pic_size%3D2

Check domain:
URL:http://Vera_IP/port_3480/data_request?id=lu_wget&url=http://ip.winninghamfamily.com:8000 returns with 200 status OK

Try and get image.
Request URL:
http://Vera_IP/port_3480/data_request?id=lu_wget&url=http://ip.winninghamfamily.com:8000/cgi-bin%2Fwappaint%3Fcamera_no%3D1%26animation%3D0%26name%3Dtester%26password%3D1234%26pic_size%3D2

Request Method:
GET

Status Code:
HTTP/1.1 502 Bad Gateway

The camera URL is a parameter to http://Vera_IP/port_3480/data_request? and should be encoded but it’s only half encoded. It likes like Vera is a bit confused on what to do with the camera URL?? Only option is to get out WireShark and see what Vera actually requests.

This whole handling of camera URLs is a dogs breakfast.

Looked at this further - if you look at the state variables, you find the camera URLs are relative to Vera and that it may not be possible to put in an absolute address???:

– add in your Vera ip address:

http://Vera_IP/port_3480/data_request?id=lu_status&output_format=xml

You could try code like this:

[code]local SERVICE_ID = ‘urn:micasaverde-com:serviceId:Camera1’
local CAMERA_URL = ‘cgi-bin/wappaint?camera_no=1&animation=0&name=tester&password=1234&pic_size=2’
local DEVICE_ID = 66 – your camera device number

luup.variable_set(SERVICE_ID, ‘URL’, CAMERA_URL, DEVICE_ID)

return true[/code]

and fiddle with the CAMERA_URL value. Restart Vera and check the state variable has changed here and retry camera:

http://Vera_IP/port_3480/data_request?id=lu_status&output_format=xml

But frankly I’m not hopeful this will work.

So, I haven’t yet tinkered under the hood on Vera at all, yet. But I accessed the XML file, and found something that looks very similar to what you’ve outlined. That is, the camera URL shows up unenconded, substantially the same as the URL value you’ve suggested:

<device status="-1" id="11">
<states>
<state id="18" value="/cgi-bin/wappaint?camera_no=1&animation=0&name=tester&password=1234&pic_size=2" variable="URL" service="urn:micasaverde-com:serviceId:Camera1"/>
<state id="19" value="5" variable="Timeout" service="urn:micasaverde-com:serviceId:Camera1"/>
<state id="20" value="0" variable="PreRollBuffer" service="urn:micasaverde-com:serviceId:Camera1"/>
<state id="21" value="0" variable="LastUpdate" service="urn:micasaverde-com:serviceId:HaDevice1"/>
<state id="22" value="0" variable="Configured" service="urn:micasaverde-com:serviceId:HaDevice1"/>
</states>
<Jobs/>
<tooltip display="0"/>
</device>

So, is it still worthwhile for me to crack my knuckles and get my hands dirty? I’d like not to, if possible… :frowning:

That all looks good.

I tried out wireshark to-day and it looks like Vera is making the correct request but the camera still doesn’t like it, as it still returns the bad gateway status. Sorry but I’m out of ideas at the moment.

had this bad gateway problem too with my eminent cam and it dissapeared when i upgraded my routers firmware.

@agentjbond - are you still out there? A bit more info for you:

I recently updated the software for my Vera 3 to 1.5.622 I was fiddling around with this new plugin:

http://forum.micasaverde.com/index.php/topic,16518.0.html

and I found that the URL for your camera was incorrect. In the Advanced settings for the camera plugin for the variable “URL” it had:

“cgi-bin/wappaint?camera_no=1&animation=0&name=tester&password=1234&pic_size=2”

when it should have this with the leading forward slash:

“/cgi-bin/wappaint?camera_no=1&animation=0&name=tester&password=1234&pic_size=2”

On changing it I found your camera was being uploaded to dropbox successfully. The drop box plugin program can clearly successfully construct the URL for your camera using the saved Vera variables for the camera. Now here’s the catch: Your camera still doesn’t show up in the user interface !! The web browser gets 404 "Not found "errors and the Vera log shows corresponding “HTTP/1.1 502 Bad Gateway” errors.

So the dropbox plugin can get the images but the UI5 code can’t. Looks like a Vera bug. However they may have improved how the url encoding is done.

James B - if you come in from the cold, have a look here:

http://forum.micasaverde.com/index.php/topic,16639.0.html