OPCFoundation / UA-.NETStandard

OPC Unified Architecture .NET Standard
Other
1.92k stars 937 forks source link

Server to listen to a specific network interface #1581

Closed andythinkiq closed 2 years ago

andythinkiq commented 2 years ago

Type of Issue

Describe the Issue

We have a business requirement to set up a OPC UA Server that listen to port 443 on an Ubuntu box along with Apache. So we added a second network interface, configured Apache to use the first one, and set the OPC UA server to use listen to port 443 on the second NIC. For example,

    <BaseAddresses>
        <ua:String>opc.tcp://54.123.456.789:443/OpcUaServer</ua:String>
    </BaseAddresses>

The problem is that OPC Server ignores the IP address, or host name, and listens to 0.0.0.0:443. This conflicts with Apache. The Start method in Stack\Opc.Ua.Core\Stack\Tcp\TcpTransportListener.cs does this when creating a socket:

    IPEndPoint endpoint = new IPEndPoint(IPAddress.Any, port);
    m_listeningSocket = new Socket(endpoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp);

To Reproduce Steps to reproduce the behavior:

  1. Set up a OPC UA Server on Ubuntu
  2. Change the BaseAddress in its Config.xml to a specific IP address
  3. Start the server
  4. From a terminal, run 'sudo netstat -tulpn | grep LISTEN'
  5. The result shows the OPC UA server is listening to 0.0.0.0:443 and :::443

Expected behavior The OPC UA server should listen on the specified IP, not IPAddress.Any.

Environment (please complete the following information):

mrsuciu commented 2 years ago

Yes, binding to a specific interface is a missing feature but will be looked into soon.