Closed NiallBegley closed 2 years ago
@NiallBegley have you tried with different network number ie. 0
?
Yeah, even if both devices are on network 0 or one is on 1 and the other is on 0 it still doesn't work
@NiallBegley I've run into this before so I did a little more digging and remembered that BSD sockets behave differently from Win32 sockets. It is my understanding that in linux you cannot receive broadcast messages when bound to an address other than INADDR_ANY
but in Windows there is no such rule.
@NiallBegley what I said didn't fix your issue can you please re-open and add more detail?
Describe the bug While running a Java application using BACnet4j I cannot receive broadcast bacnet UDP data even though I can see the UDP traffic coming in on Wireshark. This is on Ubuntu 19.04 and has been tested with both OpenJDK 8 and Oracle's JDK 8 and using BACnet4J version 6.0.0-SNAPSHOT.
To Reproduce Create a BACnet device in an java application running on the Linux machine.
On a Windows machine create another Java application that creates a device using the same code as above (but change the device number). Issue a WhoIs manually however you'd like (periodically, from pushing a button, etc).
If you issue broadcast messages from the Linux side, the application running on the Windows will pick up on them just fine. However, any broadcast messages issued from the Windows side will be ignored by BACnet4J (although you can verify the messages are coming in via Wireshark - see below).
Also, all unicast messages go through in both directions without any issues.
I've recreated this problem on multiple Linux machines including a couple VM's. None of the linux machines have firewalls.
It's also worth noting that the messages are not coming in to BACnet4J and being ignored for one reason or another - putting a breakpoint in IpNetwork's run() function shows that nothing is ever coming in from socket.receive() (unless you send unicast data, of course).
Expected behavior I'd expect the BACnet4J stack to pick up on broadcast messages as you see from Windows to Windows machine.
I've created a workaround by changing the binding of the DatagramSocket in IpNetwork.java from binding to a specific interface to just binding to a port as follows:
However, I don't consider this a valid fix as I'll now receive broadcast data on all interfaces which will probably be a problem for me at some point down the line.
Screenshots Here is the output of the ignored broadcast packet coming in to the Linux side. 192.168.1.22 is the windows machine, 192.168.1.32 is the Linux machine.
Mango Version (please complete the following information): N/A
Browser (please complete the following information): N/A
Additional context N/A
ma.log Snippet N/A
Browser console errors N/A
Minimal code example to reproduce
Address and broadcast addresses were verified through
NetworkInterface.getNetworkInterfaces()