Code-House / bacnet4j-wrapper

Simple facade for bacnet4j api.
GNU General Public License v3.0
48 stars 20 forks source link

Support for multiple IP clients sharing same socket #33

Closed saransh14 closed 6 months ago

saransh14 commented 7 months ago

Hi @splatch, Hope you're doing good.

I'm trying to solve a use case where I want to create two different BacNetIpClient on the same broadcast address, but with different clientID. Following is the method that I'm using to generated 'BacNetIpClient` BacNetIpClient client1 = new BacNetIpClient(broadcastAddress, "2002"); BacNetIpClient client2 = new BacNetIpClient(broadcastAddress, "2003");

For client2, I'm getting error while starting the client using client2.start() as Unable to initialize client.

Could you please let me know if we can create 2 BACnet client on same address but with different client IDs?

splatch commented 7 months ago

AFAIK by default its not going to work properly, because socket bound at the operating system level is owned by first client instance. I recall that a while ago there was issue in bacnet4j project to begin supporting SO_REUSEADDR options: https://github.com/MangoAutomation/BACnet4J/issues/1#issuecomment-541089441

While wrapper does not support withReuseAddress option, you can try initializing wrapper with IpNetwork created manually and see if it will fly.

saransh14 commented 7 months ago

Thanks for the confirmation @splatch. Closing the issue as the information is received.

splatch commented 7 months ago

I think we can keep it open, if bacnet4j supports that we can pull one more option to propagate this setting and shade calls to IpNetworkBuilder.

saransh14 commented 7 months ago

Sure @splatch please let me know once it is available in the library, post that I'll integrate it with my service to handle this use case.

saransh14 commented 7 months ago

Hi @splatch , any tentative date by when can I expect the support to be available in the library, so that I can extend the same for my use case?

saransh14 commented 6 months ago

Hi @splatch , thanks for sharing the reference link to the issue from MangoAutomation/BACnet4J library. I've used the same way of creating IpNetwork using the withReuseAddress and then created BacnetIpClient, and was able to create multiple clients using that way on same broadcastAddress. Thanks for your help.

splatch commented 6 months ago

Hello @saransh14, I've added one liner for this issue and another for bug I found. I'll cut a new release once we get back mango automation maven repository server (see MangoAutomation/BACnet4J#86).

saransh14 commented 6 months ago

Hi @splatch , the release build is failing on Github actions, can you please look into it.

splatch commented 6 months ago

Yeah, there were some changes in infrastructure. Will address it today.

splatch commented 6 months ago

Release 1.3.0-beta1 is on its way to maven central. The release build and maven central validation have passed. Artifacts should be available within hour or so.