Last post May 16, 2016 06:03 AM by Dude123
Apr 26, 2016 08:00 AM|Dude123|LINK
I have a SignalR application running in self hosted OWIN listening on all interfaces:
servHost = WebApp.Start(Of OwinConfig)(http://+:8080)
Need to get the IP address currently servicing clients. Before you suggest using "Net.Dns.GetHostEntry()" keep in mind that this can't distinguish between local interfaces and VMWare created virtual interfaces. They both are local to the machine but OWIN
does not serve through those. So rather than asking the system to enumerate its interfaces I though there might be a way to interogate OWIN or SignalR of the IP address it is currently using to serve clients.
Apr 27, 2016 06:03 AM|Fei Han - MSFT|LINK
You could try to retrieve the client’s IP address from Request.Environment.
May 01, 2016 09:10 AM|Dude123|LINK
The Request.Environment only privides the client IP after a request has been made. But I need the IP of the server (not the client) on which SignalR is open and ready to service requests so I can give it to the clients so they can make that request to begin
You see, I have a home automation application with the server component being a self hosted OWIN SignalR service used in a LAN environment. The LAN clients need to know what the server address of the SignalR endpoints are, so they can connect to them. My
server application has a UI that needs to display its IP so the clients know where to connect. The user of the client and the server are the same people on their home LAN.
May 04, 2016 11:08 AM|Khuram.Shahzad|LINK
// Establish the local endpoint for the socket.
// Dns.GetHostName returns the name of the
// host running the application.
IPHostEntry ipHostInfo = Dns.Resolve(Dns.GetHostName());
IPAddress ipAddress = ipHostInfo.AddressList;
IPEndPoint localEndPoint = new IPEndPoint(ipAddress, 11000);
May 16, 2016 06:03 AM|Dude123|LINK
Yea, tried this before posting. Unfortunately this only works in limited scenarios. Reports wrong IP if the server PC is connected to a VPN or if PC has virtual adapters for VMWare. That's because this code doesn't realy interogate OWIN nor SignalR about
the endpoint IP that it is actually serving but instead takes a general approach by looking at the available network adapters of which there could be many and are listed in an undeteminant order.