agsh / onvif

ONVIF node.js implementation
http://agsh.github.io/onvif/
MIT License
681 stars 231 forks source link

Regression: getSnapshotUri() broken in master #232

Open sjkummer opened 2 years ago

sjkummer commented 2 years ago

After Updating to the newest master getSnapshotUri() does not work correctly anymore, but throws an exception:

18:09:06.339 [WARN]  Failed to get camera snapshot: TypeError: Cannot read property 'media' of undefined
TypeError: Cannot read property 'media' of undefined
    at Cam._request (xxx/node_modules/onvif/lib/cam.js:215:15)
    at Cam.getSnapshotUri (/xxx/node_modules/onvif/lib/media.js:1132:9)

This worked in earlier versions.

Cam: Samsung Wisenet QND-7010R ... camera is not officially onvif certified, but the null pointer because of the missing null check is probably not good.

agsh commented 2 years ago

@sjkummer Hi again! Also pls send me the response from the cam. This lib was written a long time ago. I'm trying to rewrite it in typescript and modern js, but I don't have time for that: https://github.com/agsh/onvif/tree/v1

RogerHardiman commented 2 years ago

I wonder if the problem is the Media2 API changes.

About 4 months ago I added support for the Media2 APIs to allow me to get H265 stream details from newer cameras. That required me to implement a Media2 API version of getSnapshotUri.

Do you know what version you had that used to work?

Thanks Roger

RogerHardiman commented 2 years ago

Bad news. My own Samsung Hanwha Wisenet camera has not come back up after recabling. It powered on once and ODM would see it on the network but did not give me any video. The web page did not load properly. After a power cycle it is dead. So I cannot test on my Wisenet camera.

We'll need you to capture the XML traffic and send it over.

RogerHardiman commented 2 years ago

If you can give me some remote access t the camera, I can take a closer look

sjkummer commented 2 years ago

Hey there, I tried to reproduce this issue today, but the behaviour was different.

media2Support was true today for that cam. When I got that null pointer / TypeError (original description), that was set to false. (But: when looking at the code, that TypeError might still happen when this.uri is missing at https://github.com/agsh/onvif/blob/master/lib/cam.js#L215 )

I am not sure whats different, but I got a successful response when using getSnapshotUri without options.