You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
cam.getSnapshotUri() not working with public camera id #336
I am connecting to a camera with its public Ip as it is not on my local network,
constcam=newCam({username: "xx",password: "xx",hostname: "x.x.x.x",port: x,},asyncfunction(err){if(err){console.error("Failed to connect to the camera:",err.message||err);returnreject(newError(`Connection failed: ${err.message||err}`));}awaitcam.getSnapshotUri({stream: "RTP-Multicast",protocol: "RTSP"},function(err,data){console.log(data);});});
data returns { uri: undefined }
what did i miss? or isn't it possible to take a snapshot with that connection?
Spotted a few eroors in the code.
a) You only need Stream (Multicast) and Protocol (RTSP) for Get StreamUri(). You do not need them for GetSnapshotUri
b) The await on getStreamuri does nothing. The library is a "function with callback" type of library, unless you pass the library through Promisify and then you can use await and would not have a callback.
If you were trying to wait for it to finish, and then resolve a promise, you'd call resolve after console.log(data)
Spotted a few eroors in the code. a) You only need Stream (Multicast) and Protocol (RTSP) for Get StreamUri(). You do not need them for GetSnapshotUri
b) The await on getStreamuri does nothing. The library is a "function with callback" type of library, unless you pass the library through Promisify and then you can use await and would not have a callback. If you were trying to wait for it to finish, and then resolve a promise, you'd call resolve after console.log(data)
Could I have remote acccess to the camera - (I realise this was 2 years ago) please
It is also possible that this is a camera that does not implement cam.getSnapshotUri().
That ONVIF API is only needed in Profile T devices. If it is an older ONVIF Device (Profile s) then it may not be available for your user login.
Activity
RogerHardiman commentedon Oct 16, 2024
Spotted a few eroors in the code.
a) You only need Stream (Multicast) and Protocol (RTSP) for Get StreamUri(). You do not need them for GetSnapshotUri
b) The await on getStreamuri does nothing. The library is a "function with callback" type of library, unless you pass the library through Promisify and then you can use await and would not have a callback.
If you were trying to wait for it to finish, and then resolve a promise, you'd call resolve after console.log(data)
this may not explain why it fails though
JooZef315 commentedon Oct 16, 2024
thank you for replying @RogerHardiman,
refactored it to this, but still the same error
NdiayeeCheikh commentedon Apr 14, 2025
You can use an api according to your framework, i'm using nextjs by the way.
Inside the api , just do a soap request :
import DigestClient from 'digest-fetch';
import { parseStringPromise } from 'xml2js'; // Utilisation de xml2js pour parser le XML
export async function POST(req) {
try {
const body = await req.json();
const ip = body.ip;
const profileToken = body.profileList[0];
console.log('IP:', ip);
console.log('ProfileToken:', profileToken);
} catch (err) {
return new Response(JSON.stringify({ error: err.message }), {
status: 500,
headers: { 'Content-Type': 'application/json' },
});
}
}
RogerHardiman commentedon Sep 30, 2026
Could I have remote acccess to the camera - (I realise this was 2 years ago) please
It is also possible that this is a camera that does not implement cam.getSnapshotUri().
That ONVIF API is only needed in Profile T devices. If it is an older ONVIF Device (Profile s) then it may not be available for your user login.