Spring boot application listens over IPv6 without -Djava.net.preferIPv4Stack=true and -Djava.net.preferIPv4Addresses parameters

柔情痞子 提交于 2019-12-23 10:50:45

问题



My question about Spring boot jar. When running jar on production machine as:

java -jar xyz.jar

It does not respond to my request. Because it is listening on ipv6.

But when I run application as
java -jar xyz.jar -Djava.net.preferIPv4Stack=true -Djava.net.preferIPv4Addresses

It responds my requests.

Is it the production machine's configuration which cause the application to listen over ipv6, or is there any other reasons?

Fortunately
-Djava.net.preferIPv4Stack=true
-Djava.net.preferIPv4Addresses
parameters solved my problem. But I am confused!!

Note: Tomcat is used as embedded server.
Spring boot version 1.5.4 RELEASE


回答1:


Here https://docs.oracle.com/javase/8/docs/technotes/guides/net/ipv6_guide/index.html I read that "The Java networking stack first checks whether IPv6 is supported on the underlying OS. If IPv6 is supported, it tries to use the IPv6 stack."

To check if your Linux machine supports IPv6, simply run "cat /proc/net/if_inet6" and if you see some output it means it's enabled.



来源:https://stackoverflow.com/questions/44718174/spring-boot-application-listens-over-ipv6-without-djava-net-preferipv4stack-tru

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!