netmq
netmq copied to clipboard
Beacon throws unhandled ArgumentNullException when there are no connected network adapters.
Environment
NetMQ Version: 4.0.1.6 / master
Operating System: Windows10 20H2 (19042.868)
.NET Version: net462
Expected behaviour
Exception should be handler and not re-thrown. Probably Beacon should handle it as interface "*".
Actual behaviour
Unhandled exception:
System.ArgumentNullException: Value cannot be null.
Parameter name: remoteEP
at System.Net.Sockets.Socket.SendTo(ByteD buffer, Int32 offset, 1nt32 size, SocketFlags socketFlags, EndPoint remoteEP)
at NetN1Q.NetNIQBeacon.Shim.SendUdpFrame(NetMO.Frame frame)
at NettVIQ.NetMQSocket.InvokeEvents(Object sender, PollEvents events)
at NetMQ.NetMQPoller.RunPoller()
at NetMQ.NetMQPoller.Run(SynchronizationContext syncContext)
at NetMQ.NetMQBeaconShim.Run(PairSocket shins)
at NetMQ.NetMQActor.RunShim0
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncttx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state; Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart0
Steps to reproduce the behaviour
Exception can be reproducer using the beacon sample. I have 2 network cards, wifi and lan. Only wifi is connected. Exception is thrown when I disconnect from wifi in windows. I have also managed to get it once with network connected and I believe that is what happening for the customer.
Same thing should theoretically happen when user disconnects from the network?
Exception is thrown by this line: https://github.com/zeromq/netmq/blob/ea0a5a7e1b77a1ade9311f187f4ff37a20d5d964/src/NetMQ/NetMQBeacon.cs#L270
It seams that when there are no connected adapters beacon is not bound to "*", loopback and goes to foreach loop. But when there are no connected network cards, InterfaceCollection return empty list and sendTo/m_broadcastAddress is never set, throwing nullref when socket is trying to send something.
https://github.com/zeromq/netmq/blob/ea0a5a7e1b77a1ade9311f187f4ff37a20d5d964/src/NetMQ/NetMQBeacon.cs#L112-L150
i am seeing same exact issue, would be good to get a fix