Closed maddie closed 2 years ago
I think I've found the problem:
I've set the limit to -1
, so the break
statement will never reach; and somehow p2.ReadFrom
never returned error, so the return
statement never reached either, and there goes the dangling listener.
Was this done by purpose, or is it just a case not tested/handled?
EDIT: Tested on both Linux (Ubuntu 20.04 x64) and macOS Big Sur, both are having the same problem.
I've wrapped the
Discover
function like this:If I'm understanding the
Settings
correctly, this should discover for 10 secs (default) for unlimited nodes, exits, and restart in 5 secs.But what I'm seeing here is that after the discovery completes, there's a lot of listeners on port 9999 (default):
Is there a way to close these listeners after the function is finished?
EDIT: The reason I'm running this in a loop is that if I set the time limit to
-1
, it works for some time; if the network changes, it will just stop discovering/being discovered altogether. So I figured maybe I'll just let it run periodically for 10 secs.