agsh / onvif

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

Error: ONVIF SOAP Fault: HTTP Error: 401 Unauthorized #158

Closed AdyRock closed 4 years ago

AdyRock commented 4 years ago

When the createPullPointSubscription is called the return is Error: ONVIF SOAP Fault: HTTP Error: 401 Unauthorized. This is a user of my app so I don't have access to the camera but it is a Foscam FI9900EP. He says there is only one user (admin) setup. If he enters the wrong user name / password then the camera will not return any device information so I presume that is correct as he is getting that. A search online shows another person with a similar issue here https://stackoverflow.com/questions/56129652/onvif-pullpointproxy-pullmessages-returns-error-401-unauthorized but I don't know if that is relevent. Can you suggest a fix?

agsh commented 4 years ago

Hi! As far as I know, in the specification there is only one method that works without authorization: getSystemDateAndTime. Am I right, @RogerHardiman ?

AdyRock commented 4 years ago

Thanks for you reply. I much appreciate your time.

That is what I thought as well. So as he is getting the device information, etc, I presume he has used the correct username and password. In the link the op there is talking about a missing header in WS-Addressing which I presume is a WebSocket header?

To whom it may consern...

The problem was in WS-Addressing header: https://www.w3.org/Submission/ws-addressing/ https://www.genivia.com/doc/wsdd/html/wsa_0.html

I added it to my PullMessage request and got a response from camera.

I can't find anything in the library about the web sockets so I am not sure if that needs to be added or if it is just a red-herring.

RogerHardiman commented 4 years ago

There are two types of ONVIF Subscription. One is Pull and one is Push. With Pull, our library has to ask the camera if it has any new events. We have to keep polling the camera all the time. The other type is Push Events where the camera sends an event to a small HTTP server running on your computer.

This library only uses the Pull method. Some cameras only support the Push method.

So it is possible your camera does not support the Pull method.

We would need to look at the XML to check, or we need a volunteer to write the Push Event code.

AdyRock commented 4 years ago

As it turns out that camera does not support events at all despite the manufacture saying it supports ONVIF and motion detection. Just not both together.

I have hacked in the code to subscribe. refresh and unsubscribe push events to the library and I setup a small server in my app to process the events, so I now support both push and pull events.

I would love to share what I have done but I don't know enough about git to give the code back (if you know what I mean). I also based it on a merge of a couple of forks in here that fixed a few problems so I have no idea how to separate it all lol. If anyone is interested my entire app is here https://github.com/AdyRock/com.onvif and the hacked ONVIF lib is in the lib folder.

RogerHardiman commented 4 years ago

Hi @AdyRock Thanks for the link to your ONVIF changes.