gpt4 book ai didi

java - VPS 上的 spring boot 应用程序没有响应

转载 作者:行者123 更新时间:2023-11-28 22:07:31 26 4
gpt4 key购买 nike

我开发了 spring boot 应用程序。我用嵌入式tomcat准备了它。当我在我的电脑上运行那个 jar 时,它一切正常。但是当我在 VPS 上运行相同的应用程序时,它被初始化,在第一次请求时它打印 dispatcherServlet 被初始化但没有任何其他响应。浏览器保持连接并且响应永远不会到来。我尝试在其他端口和类似端口上运行它,但没有运气。第一次尝试,当我只运行应用程序时它起作用了。但后来我尝试在后台运行它,从那时起,它再也没有返回任何响应。

我相信它收到了请求,因为它打印了 dispacherServlet 初始化。任何建议都会有所帮助。

最佳答案

我在我的 Spring Boot 应用程序中观察到相同的行为。但如果我等的时间足够长,我会收到以下消息:

o.a.c.util.SessionIdGeneratorBase        : Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [224,707] milliseconds.

这可能意味着您的 VPS 的熵源较弱,可能需要(非常)长时间才能完全启动。

根据tomcat wiki :

Tomcat 7+ heavily relies on SecureRandom class to provide random values for its session ids and in other places. Depending on your JRE it can cause delays during startup if entropy source that is used to initialize SecureRandom is short of entropy.

您可以通过系统属性使用非阻塞熵源:

-Djava.security.egd=file:/dev/./urandom

它有一些安全隐患,请阅读 this question on security.stackexchange.com了解详情。

关于java - VPS 上的 spring boot 应用程序没有响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44145870/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com