websocket-sharp
websocket-sharp copied to clipboard
How to get client's ip when the connection opened
How to get client's ip when the connection opened
protected override void OnOpen() { IPAddress clientIPAddress = Context.UserEndPoint.Address; }
My server is running on a machine behind a router. The router forwards packets based on the port to this machine.
Context.UserEndpoint.Address does have a valid IP address, but its the address of my router on the local network - not the IP of the client who actually made the request.
I've poked through the properties in the Context object and dont see anything obvious. Is there an way to get the original address of the requestor after the traffic has been port forwarded?
Context.UserEndPoint.Address;
is always 10.0.2.2
for me
Even when creating server with new WebSocketServer(System.Net.IPAddress.Any, 3553);
UPD: it was the problem on my side, I'm sorry. Had to switch from NAT to Bridge Network in VirtualBox VM settings.