'Need to get the actual Ip address in vaadin 8.8.5

I am trying to get the actual ip address in the vaadin version 8.8.5

below is the code I am using

VaadinRequest.getCurrent().getHeader("X-Forwarded-For")

but getting null



Solution 1:[1]

X-Forwarded-For is only added if there's a "well behaving" proxy or such in between. Absence of X-Forwarded-For either means that there isn't any proxy, or that there is a proxy that doesn't follow the general convention of adding that header.

In the case of no proxy, then you can get the IP directly from the request as VaadinRequest.getCurrent().getRemoteAddr().

In the case of a proxy that doesn't add the header, then there is unfortunately no way of finding the actual IP address. getRemoteAddr() will in that case give the IP address of the proxy instead, and you don't have any good way of knowing whether the IP is for a proxy or a real user.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Leif Åstrand