Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cam.getSnapshotUri() not working with public camera id #336

Open
JooZef315 opened this issue Oct 16, 2024 · 2 comments
Open

cam.getSnapshotUri() not working with public camera id #336

JooZef315 opened this issue Oct 16, 2024 · 2 comments

Comments

@JooZef315
Copy link

JooZef315 commented Oct 16, 2024

I am connecting to a camera with its public Ip as it is not on my local network,

      const cam = new Cam(
        {
          username: "xx",
          password: "xx",
          hostname: "x.x.x.x",
          port: x,
        },
        async function (err) {
          if (err) {
            console.error("Failed to connect to the camera:", err.message || err);
            return reject(new Error(`Connection failed: ${err.message || err}`));
          }         
          await cam.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?

@RogerHardiman
Copy link
Collaborator

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
Copy link
Author

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

thank you for replying @RogerHardiman,

refactored it to this, but still the same error

cam.getSnapshotUri(
{ profileToken: cam.activeSource.profileToken },
function (err, data) {
  console.log(data);
}
);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants