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

Failed to initialize the device #22

Open
AngThomas opened this issue Jan 13, 2018 · 9 comments
Open

Failed to initialize the device #22

AngThomas opened this issue Jan 13, 2018 · 9 comments

Comments

@AngThomas
Copy link

AngThomas commented Jan 13, 2018

Hello,

I got this:
Failed to initialize the device: Error: Networ Error: socket hang up at services.media.getProfiles (node_modules\node-onvif\lib\modules\device.js:464:12) at promise.then.catch (node_modules\node-onvif\lib\modules\service-media.js:392:4) at<anonymous>

I try to launch example of Create OnvifDevice object:

'const onvif = require('node-onvif');
// Create an OnvifDevice object
let device = new onvif.OnvifDevice({
xaddr: 'http://IP:PORT/onvif/device_service',
user : 'xxxx',
pass : 'xxxx'
});

// Initialize the OnvifDevice object
device.init().then((info) => {
// Show the detailed information of the device.
console.log(JSON.stringify(info, null, ' '));
}).catch((error) => {
console.error(error);
});'

It gives me this error when I try to launch it on Windows Server 2012, but when I launch it on my pc (Win 10), it works fine. I tried to turn off firewall, make in and outbound rules, with no success. The camera has public is behind router and has forwarded ports.
Any help is appreciated.

EDIT So it turned out, that it doesn't work on my local pc either. It was connecting to my LAN IP cam, even though I typed IP address of public IP camera.
EDIT2 It is getting stranger, and stranger. When I my local IP cam connected to router, the app can connect both to local, and public IP cam (I can tell by Hardware ID), but when I disconnect local IP camera, it suddenly can't connect to public camera. When I try snapshot app and type public IP it gets snapshot...from local IP camera.

@futomi
Copy link
Collaborator

futomi commented Feb 11, 2018

I've not find the reason yet. I updated the node-onvif today. Though I'm not sure this issue is solved, try the latest version of the node-onvif.

@mishitpatel
Copy link

@futomi I am able to discover the device properly but not able to connect it. It throws below error

Error: Failed to initialize the device: Error: 400 Bad Request - Sender not authorized
    at services.device.getCapabilities (/Users/Mishi/kiwi/repo/camera/node_modules/node-onvif/lib/modules/device.js:392:12)
    at promise.then.catch (/Users/Mishi/kiwi/repo/camera/node_modules/node-onvif/lib/modules/service-device.js:120:4)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)

I have verified that username and password is correct. I am able to invoke ONVIF api through SOAP client with same username and password. I am using AXIS camera. Any idea what would be wrong ? Thanks in advance.

@davidgatti
Copy link
Contributor

@futomi The issue is how your code authenticates to the camera. You should send the authentication in the header. You instead pass the user name and password in the body. It seams that you have this feature in http-auth.js but are using this module only in the .fetchSnapshot() function.

Is there a reason why you do it this way?

@futomi
Copy link
Collaborator

futomi commented Apr 18, 2018

@davidgatti Thank you for your advice. I'll try to check the code this weekend.

@TutorJoes-Stanley
Copy link

Error: Failed to initialize the device: Error: 400 Bad Request - Sender not Authorized
at services.device.getDeviceInformation (C:\Users\tutor\Desktop\RTSP-STREAM\node_modules\node-onvif\lib\modules\device.js:453:12)
at promise.then.catch (C:\Users\tutor\Desktop\RTSP-STREAM\node_modules\node-onvif\lib\modules\service-device.js:853:4)
at process._tickCallback (internal/process/next_tick.js:68:7)

@TutorJoes-Stanley
Copy link

I have same problem can any one help me

@neonmura
Copy link

neonmura commented Jul 9, 2019

Error: Failed to initialize the device: Error: 400 Bad Request - Sender not Authorized
at services.device.getDeviceInformation (C:\Users\tutor\Desktop\RTSP-STREAM\node_modules\node-onvif\lib\modules\device.js:453:12)
at promise.then.catch (C:\Users\tutor\Desktop\RTSP-STREAM\node_modules\node-onvif\lib\modules\service-device.js:853:4)
at process._tickCallback (internal/process/next_tick.js:68:7)

Normally this happens when the clock in your client and camera differs more than 5 secs. I've noticed that in my camera, and solved it by either syncing both camera and client to same NTP or disable the function of "replay attack protection" in the axis camera.

@zainiazhr14
Copy link

its because user not have permission for access

@bradjin8
Copy link

bradjin8 commented Aug 2, 2022

Error: Failed to initialize the device: Error: 400 Bad Request - Sender not authorized at /Volumes/DATA/Web/Onvif/node_modules/node-onvif/lib/modules/device.js:396:12 at /Volumes/DATA/Web/Onvif/node_modules/node-onvif/lib/modules/service-device.js:120:4 at processTicksAndRejections (node:internal/process/task_queues:96:5)
It has still the same issue.
@futomi

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

8 participants