Summary
When connecting to a discovered WiFi device, bind the TCP connection to the same local network interface that discovered the device. This prevents connection issues in multi-NIC scenarios.
Problem
When a system has multiple network interfaces (e.g., Ethernet + WiFi, or multiple WiFi adapters), and different interfaces have routes to the same IP address (192.168.1.1 is common for both home routers and DAQiFi devices in AP mode), TCP connections may be routed through the wrong interface.
Symptoms:
- Connection timeouts when trying to connect to discovered devices
- Connections succeeding but to the wrong device (e.g., router instead of DAQiFi)
- Intermittent connection failures depending on Windows routing table state
Proposed Solution
1. Update DeviceInfoConverter.ToWiFiDevice() to populate LocalInterfaceAddress
Once daqifi/daqifi-core#88 is implemented, update the converter:
public static DaqifiStreamingDevice ToWiFiDevice(CoreDeviceInfo coreInfo)
{
var deviceInfo = ToDesktopDeviceInfo(coreInfo);
var device = new DaqifiStreamingDevice(deviceInfo);
// Propagate local interface for TCP binding
if (coreInfo.LocalInterfaceAddress != null)
{
device.LocalInterfaceAddress = coreInfo.LocalInterfaceAddress.ToString();
}
return device;
}
2. Update DaqifiStreamingDevice.Connect() to bind to local interface
public override bool Connect()
{
try
{
// If we know which local interface discovered this device, bind to it
if (!string.IsNullOrEmpty(LocalInterfaceAddress))
{
var localEndpoint = new IPEndPoint(IPAddress.Parse(LocalInterfaceAddress), 0);
Client = new TcpClient(localEndpoint);
AppLogger.Information($"Binding TCP to local interface {LocalInterfaceAddress} for {IpAddress}");
}
else
{
Client = new TcpClient();
}
// ... rest of connection logic
}
}
Dependencies
Context
This was originally part of PR #173, which has been closed because the multi-interface UDP discovery moved to Core. The TCP binding feature needs to be re-implemented once Core provides the local interface information.
Acceptance Criteria
Summary
When connecting to a discovered WiFi device, bind the TCP connection to the same local network interface that discovered the device. This prevents connection issues in multi-NIC scenarios.
Problem
When a system has multiple network interfaces (e.g., Ethernet + WiFi, or multiple WiFi adapters), and different interfaces have routes to the same IP address (192.168.1.1 is common for both home routers and DAQiFi devices in AP mode), TCP connections may be routed through the wrong interface.
Symptoms:
Proposed Solution
1. Update
DeviceInfoConverter.ToWiFiDevice()to populateLocalInterfaceAddressOnce daqifi/daqifi-core#88 is implemented, update the converter:
2. Update
DaqifiStreamingDevice.Connect()to bind to local interfaceDependencies
Context
This was originally part of PR #173, which has been closed because the multi-interface UDP discovery moved to Core. The TCP binding feature needs to be re-implemented once Core provides the local interface information.
Acceptance Criteria
DaqifiStreamingDevicehasLocalInterfaceAddresspropertyDeviceInfoConverterpopulatesLocalInterfaceAddressfrom Core'sIDeviceInfoDaqifiStreamingDevice.Connect()binds TCP socket to local interface when availableLocalInterfaceAddressis not set