Closed colinl closed 1 year ago
Hey Colin (@colinl),
In the Device section on the readme page, there is an example flow. The last inject node in that flow allows to send a "reconnect" option. Could that perhaps be used to solve your problem?
Otherwise we could perhaps add an option to the Config node to reconnect automatically (with x time in between). But it seems to me that the first option is much more powerfull, because you can add some logic in your flow when you want to reconnect.
Please let me know if this is sufficient for you! Bart
Thanks, I had missed that. Of course it isn't a permanent connection like MQTT for example which is continually monitored. Unfortunately the reconnect doesn't work for me. The node passes on
msg : Object
object
xaddr: "camera.local"
action: "reconnect"
payload: ""
_msgid: "469543a.7391dbc"
but doesn't reconnect. There is nothing in the log. A full deploy does connect.
Hi, is there any update on this? I'm having the same issue and the reconnect action doesn't work. From the node-red-log I get "Action reconnect is not supported".
If I restart the flows everything works again
@lorenzoconforti ,
Unfortunately I haven't been developing this node any further due to a lack of free time... To which node are you sending the "reconnect" action? Because the Device node should be able to recognize it:
To which node are you sending the "reconnect" action? The events node
@lorenzoconforti, I have quickly added the "reconnect" action to the Event node. Could you please test this and give me feedback. Due to a technical issue with my private event stream, unfortunately I was not able to test this new code snippet myself...
Hi, thank you for your reply. I've installed the new version (using the command "npm install bartbutenaers/node-red-contrib-onvif-nodes"); I've tried again but it does not work. The device is always in the "Disconnected" state
The events node does not give me an error in the logs anymore but still, it doesn't work. Could it be an issue with my camera (Dahua)?
As a workaround, I'm checking the status of the node and restart Node Red if I get any disconnect
@lorenzoconforti,
The problem with Onvif is that each brand has its own implementation. And I'm by far a camera expert, so don't know anything about Dahua. But it is a known brand, so I assume they have a decent implementation.
Secondly I use an Onvif library, so I cannot extra logging or whatever. So we will need to use some trial and error, and hopefully we can find what is causing your issue... But perhaps the problem is inside my node: e.g. it could be that the connection
Would be nice if I could add some own extra logging with your help, so we can avoid that other people have to go through the same troubles as you ...
Some basic questions to understand your setup.
At startup my Onvif nodes connect automatically to the camera, which fails in your case I assume. Perhaps I should add an "auto connect" checkbox in the config node screen, so you can deactivate that behaviour. Not sure if that would help ...
Hi,
Thank you
Morning,
- I see "connected" in the other nodes I'm using (discovery, event and device)
I'm a bit confused now. When you say "other" nodes, which node does not show "connected" then? Or do all nodes show "connected" but they are not really connected? Can you please clarify this a bit in more detail please. A sequence would help me to understand your setup, for example:
- The issue is on startup; the cameras take long to boot and the nodes timeout.
So it might be useful that I add an "autoconnect" checkbox on the config screen, which you can deactivate (since you know in front that you will get a timeout). Or not?
Now off to work ;-(
Hi, apologies for the confusion.
Sequence of events:
Will the autoconnect feature keep trying to connect to the cameras until they are "connected"? If that's what you have in mind, that would be perfect
Thank you
Is there a good reason why one would not want it to automatically attempt reconnection? For example the MQTT nodes don't have such an option, it is assumed that reconnection when possible is desirable.
Thanks for the extra clarification!!
So you cannot connect by sending a "reconnect" action, but you can connect by restarting Node-RED. Will "try" to see how the Onvif library differs in both scenarios...
About the autostart:
@colin: should there be an adjustable reconnect interval?
About the reconnect interval, I suppose the question is why would anyone want to adjust it? Thinking of MQTT again one can't change the interval (at least not in node-red, I don't know whether the underlying library allows that).
question is why would anyone want to adjust it?
Well because when I hardcode the interval length, then I have to make up a value that fits every use case. Not sure if there is one single best value...
After node red restarts all nodes are connected
That is weird. I'm not at my computer, but could it be that - after sending a "reconnect" - the node is "connected" but shows "disconnected"? I mean can you get info from my node then (e.g. system date time)? Because in both cases the same 'connect' function of the Onvif library is being called: both at reconnect and restart (as I can see in the Onvif library). So it should react the same way in both scenarios...
Whether that causes your problem, I'm not sure. But I need to fix my "reconnect" callback handler anyway, to update the node status...
What use cases would require different reconnect intervals?
Not sure. Will tell you as soon as someone has asked me to make it configurable ;-)
Have you seen my question above? Could it be that the node incorrectly displays "unconnected", while it is in fact "connected" after the "reconnect" action? In that case it would respond e.g. to a getSystemDateTime action?
I presume the second part of the comment is addressed to @lorenzoconforti
I've restarted the system today and the cameras are both showing "disconnected"
I've tried all the actions you see in the screenshot and none is responding (as you can see I have a debug node there); the only one that outputs something to the debug node is the reconnect action. This is what is giving in the debug window:
Even though it seems it is doing something, the cameras are still reported as disconnected and all the other action keep giving no result/response.
If I restart the flows, the cameras now show as connected:
The actions are now working as expected; see below the output in the debug window of the system datetime action:
Damn that is not what I expected/hoped. Will try to find some time next weekend to experiment with disconnecting one of my own camera's...
Hi guys (@colinl & @lorenzoconforti),
Sorry for the delay, but too much things to do in my limited free time.
I have been experimenting with one of my Onvif camera's, and I have pushed the following changes to this Github repository:
When I send a "reconnect" action, the node status is now updated (to "connected" or "disconnected").
In the config node it is now possible to adjust the timeout interval (i.e. the number of seconds that we wait for a response when trying to connect to the camera):
In the config node it is now also possible to set a connection check interval (i.e. the number of seconds between periodical checks of the connection):
When the connection check (see previous point) detects that a camera becomes connected, this node will now load all the Onvif configuration data from the camera. So hopefully now you don't need to restart Node-RED anymore to achieve the same ....
TODO: I will update the documenation on the readme file afterwards. And I should also add a validation to the config node screen: error if the timeout interval is greater than the connection check interval.
@bartbutenaers thank you for the update. The system I've set up is now live (i.e. I want to avoid any risk of breaking it); do you think these changes you've implemented are stable enough?
@lorenzoconforti, I have done quite some tests, and for me it seemed to be working correctly. But your camera's might respond entirely different, since each Onvif implementation differs. There is no way I can guarantee that it won't be broken. Moreover since you have reported this issue, you are the only one that can confirm whether this fix solves your problems. Since this is open-source, I always keep hoping that people are prepared at least to do some tests after I have spend my free time to build a fix for their problems ...
Hi Bart, I can't test at the moment as I am away from home. Will give it a go when I get back.
@bartbutenaers, apologies for the long delay. I've just finished updating my implementation and finally properly tested the new version and confirm it works as expected. After losing the connection to the camera, it is then reestablished and everything keeps working fine.
Again, apologies for the delay but I have only been able to update my system now.
Thank you very much for your support
I am sorry to say that it seems I did not feedback the results after upgrading. It is working perfectly. Thanks.
Hi guys, No problem at all! Thanks for confirming
To replicate disconnect the network connection to the camera (or power camera down) and re-deploy. The Onvif nodes show Disconnected as they should. Now reconnect the camera. The onvif nodes do not connect.
This is a particular nuisance on a PI 4 that I have. On reboot node-red starts up before the network is up and running so the onvif nodes do not connect. I have to re-deploy to get them to connect. A workaround is to get the node-red service to wait for the network before starting up, just need to work out how to do that.