agsh / onvif

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

add option in probe function that allow set specific listen port #208

Closed viettel-solutions closed 2 years ago

viettel-solutions commented 2 years ago

Resolve issue #198 Hi @agsh. Can i solve problem a this way. Just adding listeningPort option to the function

viettel-solutions commented 2 years ago

Dear @agsh ,

It has been a while that I did not hear from you back. Could you kindly check my solution? I am looking forward to hearing from you soon.

Kind regards,

RogerHardiman commented 2 years ago

Hi The change looks OK but before I merge it, I wanted to ask how it is used so we can add some documentation in the README. Normally with ONVIF we send a broadcast UDP Packet to 3702 and cameras reply back on Port 3702.

Is this for a non-standard camera that replies on a different port, or do you have a way to tell the camera what port to reply on?

Just trying to understand so we can document the usage in the README.

Thanks Roger

viettel-solutions commented 2 years ago

Dear @RogerHardiman,

Thank you for your response. This option tells the camera to know what port to reply on. Because when I use the lib to run in my server, which set up a iptable (firewall), it forces me to use only a few specified ports, so I must set it when using the lib to do it.

Many thanks, Viettel Solutions

RogerHardiman commented 2 years ago

do you run the change with the listenAddress set to 3702 ?

viettel-solutions commented 2 years ago

Dear @RogerHardiman, Yes, i did it. i ran the change with the listenAddress set to 3702. it run nomally. Or, If listenAddress options isn't set, default bind port is 3702. And, this is a example to use it. Need to set specific device options (network interface). onvif.Discovery.probe({ device:'enp2s0', listeningPort: 3705 }); Thanks Viettel Solutions

RogerHardiman commented 2 years ago

Thanks for the information. I think we should always be listening for the reply on 3702, that is the ONVIF standard listen port. I think what we currently have is a bug, listening on any port for the broadcast (multicast address).

So we could change the socket.bind to be fixed on port 3702 and not pass in the extra parameter.

Would that work for you - the port fixed at 3702 all the time?

Roger

viettel-solutions commented 2 years ago

Dear @RogerHardiman,

As I know, ONVIF::DiscoverySendProbe send probe to multicast address and port according to [WS-Discovery]. In this document, it only specifies for port and ip multicast, but not for port from source, which send multicast packet. So I think this option is completely usable. Because the multicast port is always 3702. I just set the port from the source, which sends the multicast packet. This is document I use: 3.1.1 Ad hoc mode over IP multicast of http://docs.oasis-open.org/ws-dd/discovery/1.1/wsdd-discovery-1.1-spec.html 4.3.1 ONVIF::DiscoverySendProbe of http://www.onvif.org/wp-content/uploads/2016/12/ONVIF_WG-APG-Application_Programmers_Guide-1.pdf

Thanks Viettel Solutions

viettel-solutions commented 2 years ago

Dear @RogerHardiman,

How are you doing? It has been a while since the last time we discussed it. I hope I made myself clear in the past post.

I am looking forward to hearing from you soon.

Kind regards,

RogerHardiman commented 2 years ago

Hi Thanks for the commit. If you have any other changes you want to include, please let us know.

Roger

viettel-solutions commented 2 years ago

Dear @RogerHardiman,

Thank you, i am using this lib, and if i meet any issues, i will tell you know.

Thanks Viettel Solutions