bluenviron / mavp2p

flexible and efficient Mavlink router
MIT License
127 stars 31 forks source link

Close channel after all nodes dissappear #33

Closed Kester-Broatch closed 1 year ago

Kester-Broatch commented 1 year ago

Hi there,

I noticed when you disconnect a UDP server (ip = 0.0.0.0) endpoint and we get a node disappeared message for the device(s) at that endpoint the channel never closes.

This has the effect that mavp2p will continue sending messages to that channel indefinitely, i confirmed this with wireshark. In our case it keeps sending UDP messages out into the void over cellular, so its a quite expensive issue! :sweat_smile:

So it would be good to close a UDP server channel when all known nodes on it disappear.

What are your thoughts?

Thanks, Kester

aler9 commented 1 year ago

Hello, thanks for reporting the issue. I checked and the library didn't provide any mechanism to close idle channels, so i did the following:

Kester-Broatch commented 1 year ago

Hi, thanks for implementing this fix! I will implement and test this fix in the next few weeks and get back to you :)