The check for ServiceIP == null or string.Empty fails on AWS Fargate (and perhaps other environments).
The if statement returns false and so ServiceIP isn't being set to a value.
https://github.com/pnxtech/Hydra4Net-Development/blob/master/Hydra4NET/Hydra.cs#L144
if (ServiceIP == null || ServiceIP == string.Empty)
{
using Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, 0);
socket.Connect("8.8.8.8", 65530);
if (socket.LocalEndPoint is IPEndPoint endPoint)
{
ServiceIP = endPoint.Address.ToString();
}
}
I think we should replace the contents of the if (ServiceIP == null || ServiceIP == string.Empty) statement with:
var name = Dns.GetHostName();
ServiceIP = Dns.GetHostEntry(name).AddressList.FirstOrDefault(x => x.AddressFamily == AddressFamily.InterNetwork);
The check for
ServiceIP == null or string.Emptyfails on AWS Fargate (and perhaps other environments).The
ifstatement returns false and soServiceIPisn't being set to a value.https://github.com/pnxtech/Hydra4Net-Development/blob/master/Hydra4NET/Hydra.cs#L144
I think we should replace the contents of the
if (ServiceIP == null || ServiceIP == string.Empty)statement with: