ela-compil / BACnet

BACnet protocol library for .NET :satellite:
https://www.nuget.org/packages/bacnet/
MIT License
217 stars 96 forks source link

Discovering on non-0.0.0.0 ip not working #33

Open michel-jump opened 5 years ago

michel-jump commented 5 years ago

We have BACnet implemented in a .NET core application running in Docker. BACnet runs on port 47808 on the host machine. So when I want to discover devices I use the IP of the host machine. But when I do that, it returns an error. When I check the IP and port with NMap (from within the Docker container), it shows that the port is available with service "BACnet" behind it.`

I recieve the following error:

{
    "ClassName": "System.Net.Sockets.SocketException",
    "Message": "Cannot assign requested address",
    "Data": null,
    "InnerException": null,
    "HelpURL": null,
    "StackTraceString": "   at System.Net.Sockets.Socket.UpdateStatusAfterSocketErrorAndThrowException(SocketError error, String callerName)\n   at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress socketAddress)\n   at System.Net.Sockets.Socket.Bind(EndPoint localEP)\n   at System.IO.BACnet.BacnetIpUdpProtocolTransport.Open()\n   at System.IO.BACnet.BacnetIpUdpProtocolTransport.Start()\n   at System.IO.BACnet.BacnetClient.Start()\n   at AgentCore.Services.BACnetDiscoveryService.Discover() in /app/AgentCore/Services/BACnetDiscoveryService.cs:line 41\n   at AgentApi.Controllers.DevicesController.Get() in /app/AgentApi/Controllers/DevicesController.cs:line 30",
    "RemoteStackTraceString": null,
    "RemoteStackIndex": 0,
    "ExceptionMethod": null,
    "HResult": -2147467259,
    "Source": "System.Net.Sockets",
    "WatsonBuckets": null,
    "NativeErrorCode": 99
}

Can someone enlighten me and point me in the right direction? Or is it just not possible with the library to use another ipaddress than 0.0.0.0?

MatthijsvdVeer commented 4 years ago

Old issue, but I ran into this yesterday. I fixed it by setting my container to run on the host network. docker run --rm -d --network host some-image