Spring Boot应用程序在Heroku代码= H10上崩溃

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Spring Boot应用程序在Heroku代码= H10上崩溃相关的知识,希望对你有一定的参考价值。

我已经在heroku应用程序上部署了springboot应用程序。该应用程序可以正常工作很长时间。但是现在突然我收到错误代码“ H10”,应用程序崩溃了。部署到heroku时,构建成功,并且该应用程序也可以在本地运行。

该应用程序位于git存储库中:https://github.com/hmanoharan-12/saloncityservice

我向API发送请求时收到错误。例如:-https://saloncityservice.herokuapp.com/getuser

日志错误:

2019-11-03T05:56:00.133635+00:00 app[web.1]: at com.webservice.restfulservice.ServiceApplication.main(ServiceApplication.java:10) ~[classes!/:0.0.1-SNAPSHOT]
2019-11-03T05:56:00.133637+00:00 app[web.1]: at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_222-heroku]
2019-11-03T05:56:00.133638+00:00 app[web.1]: at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_222-heroku]
2019-11-03T05:56:00.13364+00:00 app[web.1]: at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_222-heroku]
2019-11-03T05:56:00.133641+00:00 app[web.1]: at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_222-heroku]
2019-11-03T05:56:00.133642+00:00 app[web.1]: at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) ~[demo-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
2019-11-03T05:56:00.133643+00:00 app[web.1]: at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) ~[demo-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
2019-11-03T05:56:00.133645+00:00 app[web.1]: at org.springframework.boot.loader.Launcher.launch(Launcher.java:51) ~[demo-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
2019-11-03T05:56:00.133646+00:00 app[web.1]: at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:52) ~[demo-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
2019-11-03T05:56:00.133651+00:00 app[web.1]: Caused by: com.mysql.cj.exceptions.CJCommunicationsException: Communications link failure
2019-11-03T05:56:00.133653+00:00 app[web.1]:
2019-11-03T05:56:00.133654+00:00 app[web.1]: The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
2019-11-03T05:56:00.133656+00:00 app[web.1]: at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_222-heroku]
2019-11-03T05:56:00.133657+00:00 app[web.1]: at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:1.8.0_222-heroku]
2019-11-03T05:56:00.133658+00:00 app[web.1]: at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_222-heroku]
2019-11-03T05:56:00.13366+00:00 app[web.1]: at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[na:1.8.0_222-heroku]
2019-11-03T05:56:00.133661+00:00 app[web.1]: at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:61) ~[mysql-connector-java-8.0.17.jar!/:8.0.17]
2019-11-03T05:56:00.133663+00:00 app[web.1]: at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:105) ~[mysql-connector-java-8.0.17.jar!/:8.0.17]
2019-11-03T05:56:00.133664+00:00 app[web.1]: at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:151) ~[mysql-connector-java-8.0.17.jar!/:8.0.17]
2019-11-03T05:56:00.133666+00:00 app[web.1]: at com.mysql.cj.exceptions.ExceptionFactory.createCommunicationsException(ExceptionFactory.java:167) ~[mysql-connector-java-8.0.17.jar!/:8.0.17]
2019-11-03T05:56:00.133667+00:00 app[web.1]: at com.mysql.cj.protocol.a.NativeSocketConnection.connect(NativeSocketConnection.java:91) ~[mysql-connector-java-8.0.17.jar!/:8.0.17]
2019-11-03T05:56:00.133668+00:00 app[web.1]: at com.mysql.cj.NativeSession.connect(NativeSession.java:150) ~[mysql-connector-java-8.0.17.jar!/:8.0.17]
2019-11-03T05:56:00.13367+00:00 app[web.1]: at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:947) ~[mysql-connector-java-8.0.17.jar!/:8.0.17]
2019-11-03T05:56:00.133671+00:00 app[web.1]: at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:817) ~[mysql-connector-java-8.0.17.jar!/:8.0.17]
2019-11-03T05:56:00.133673+00:00 app[web.1]: ... 61 common frames omitted
2019-11-03T05:56:00.133675+00:00 app[web.1]: Caused by: java.net.SocketTimeoutException: connect timed out
2019-11-03T05:56:00.133676+00:00 app[web.1]: at java.net.PlainSocketImpl.socketConnect(Native Method) ~[na:1.8.0_222-heroku]
2019-11-03T05:56:00.133678+00:00 app[web.1]: at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) ~[na:1.8.0_222-heroku]
2019-11-03T05:56:00.133679+00:00 app[web.1]: at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) ~[na:1.8.0_222-heroku]
2019-11-03T05:56:00.13368+00:00 app[web.1]: at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) ~[na:1.8.0_222-heroku]
2019-11-03T05:56:00.133682+00:00 app[web.1]: at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~[na:1.8.0_222-heroku]
2019-11-03T05:56:00.133683+00:00 app[web.1]: at java.net.Socket.connect(Socket.java:589) ~[na:1.8.0_222-heroku]
2019-11-03T05:56:00.133684+00:00 app[web.1]: at com.mysql.cj.protocol.StandardSocketFactory.connect(StandardSocketFactory.java:155) ~[mysql-connector-java-8.0.17.jar!/:8.0.17]
2019-11-03T05:56:00.13369+00:00 app[web.1]: at com.mysql.cj.protocol.a.NativeSocketConnection.connect(NativeSocketConnection.java:65) ~[mysql-connector-java-8.0.17.jar!/:8.0.17]
2019-11-03T05:56:00.133694+00:00 app[web.1]: ... 64 common frames omitted
2019-11-03T05:56:00.133695+00:00 app[web.1]:
2019-11-03T05:56:00.213001+00:00 app[web.1]: 2019-11-03 05:56:00.212  INFO 4 --- [           main] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [
2019-11-03T05:56:00.213005+00:00 app[web.1]: name: default
2019-11-03T05:56:00.213006+00:00 app[web.1]: ...]
2019-11-03T05:56:00.327049+00:00 app[web.1]: 2019-11-03 05:56:00.326  INFO 4 --- [           main] org.hibernate.Version                    : HHH000412: Hibernate Core 5.3.11.Final
2019-11-03T05:56:00.329135+00:00 app[web.1]: 2019-11-03 05:56:00.328  INFO 4 --- [           main] org.hibernate.cfg.Environment            : HHH000206: hibernate.properties not found
2019-11-03T05:56:00.586215+00:00 app[web.1]: 2019-11-03 05:56:00.585  INFO 4 --- [           main] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations 5.0.4.Final
2019-11-03T05:56:00.990198+00:00 app[web.1]: 2019-11-03 05:56:00.989  INFO 4 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
2019-11-03T05:56:18.877745+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 90 seconds of launch
2019-11-03T05:56:18.910371+00:00 heroku[web.1]: Stopping process with SIGKILL
2019-11-03T05:56:19.00654+00:00 heroku[web.1]: Process exited with status 137
2019-11-03T05:56:19.052964+00:00 heroku[web.1]: State changed from starting to crashed
2019-11-03T05:56:47.774128+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/getuser" host=saloncityservice.herokuapp.com request_id=d15a28c2-0725-45de-a2e9-b41f9e3469d0 fwd="123.231.87.83" dyno= connect= service= status=503 bytes= protocol=https```
答案

请确保您按照--server.port=$PORT上的Heroku文档所述通过Setting the HTTP Port for Java Applications

以上是关于Spring Boot应用程序在Heroku代码= H10上崩溃的主要内容,如果未能解决你的问题,请参考以下文章

使用 nginx 作为代理的 Spring Boot 应用程序部署在 Heroku 上

Heroku H14(没有运行 Web 进程)+ Spring-boot

在heroku上部署spring boot应用程序的问题

在 Heroku 中部署我的 Gradle (Spring Boot) 应用程序

Spring Boot + Angular 2 Heroku 部署

具有 Postgresql 部署的 Spring Boot MVC 应用程序在 Heroku 中失败