Why request.getRemoteAddr() returns ipv4 or ipv6 depending on context (post query or ajax query)

前端 未结 3 867
鱼传尺愫
鱼传尺愫 2021-01-30 23:10

I\'ve donne a web app with Spring/GWT that uses Flash to upload files.

When I send an ajax request with GWT and try to get the user ip address, I get an ipv4 address lik

3条回答
  •  清歌不尽
    2021-01-30 23:15

    The reason is that the name you type in your browser has both ipv4 and ipv6 addresses. Browser chooses to use ipv4, flash chooses to use ipv6. There is nothing you can do about that on the server side (there is no way to convert).
    However, you can change your DNS and make your name have only one address, either ipv4 or ipv6. You can also connect with a literal IP address (127.0.0.1), not a name (localhost).

提交回复
热议问题