gpt4 book ai didi

java - 推送到关键时无法与端口 8080 建立 TCP 连接

转载 作者:行者123 更新时间:2023-12-02 00:25:59 27 4
gpt4 key购买 nike

我是关键云类型转换厂的新手。我在推送Java应用时出现了问题,健康检查时遇到了问题。

错误为无法与端口 8080 建立 TCP 连接:连接被拒绝

请帮我解决这个问题

编辑:我正在使用 Eureka 服务、Zuul 和中央配置。当我在本地启动应用程序时,它运行正常,但是当我推送到 PCF 时,它会收到此错误消息:

2019-09-26T17:51:08.273+07:00 [APP/PROC/WEB/0] [OUT] :: Spring Boot :: (v2.1.3.RELEASE)
2019-09-26T17:51:08.423+07:00 [APP/PROC/WEB/0] [OUT] 2019-09-26 10:51:08.418 INFO 18 --- [ main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : https://fo-config.cfapps.io/globalconfig
2019-09-26T17:51:08.982+07:00 [APP/PROC/WEB/0] [OUT] 2019-09-26 10:51:08.981 INFO 18 --- [ main] ContainerTrustManagerFactory$PKIXFactory : Adding System Trust Manager
2019-09-26T17:51:08.984+07:00 [APP/PROC/WEB/0] [OUT] 2019-09-26 10:51:08.984 INFO 18 --- [ main] ContainerTrustManagerFactory$PKIXFactory : Adding TrustManager for /etc/ssl/certs/ca-certificates.crt
2019-09-26T17:51:09.022+07:00 [APP/PROC/WEB/0] [OUT] 2019-09-26 10:51:08.994 INFO 18 --- [tificates.crt-0] org.cloudfoundry.security.FileWatcher : Start watching /etc/ssl/certs/ca-certificates.crt
2019-09-26T17:51:09.409+07:00 [APP/PROC/WEB/0] [OUT] 2019-09-26 10:51:09.409 INFO 18 --- [ main] c.s.FileWatchingX509ExtendedTrustManager : Initialized TrustManager for /etc/ssl/certs/ca-certificates.crt
2019-09-26T17:51:09.414+07:00 [APP/PROC/WEB/0] [OUT] 2019-09-26 10:51:09.414 INFO 18 --- [ main] oundryContainerKeyManagerFactory$SunX509 : Adding System Key Manager
2019-09-26T17:51:09.426+07:00 [APP/PROC/WEB/0] [OUT] 2019-09-26 10:51:09.423 INFO 18 --- [ main] oundryContainerKeyManagerFactory$SunX509 : Adding Key Manager for /etc/cf-instance-credentials/instance.key and /etc/cf-instance-credentials/instance.crt
2019-09-26T17:51:09.453+07:00 [APP/PROC/WEB/0] [OUT] 2019-09-26 10:51:09.451 INFO 18 --- [-instance.crt-0] org.cloudfoundry.security.FileWatcher : Start watching /etc/cf-instance-credentials/instance.crt
2019-09-26T17:51:09.455+07:00 [APP/PROC/WEB/0] [OUT] 2019-09-26 10:51:09.455 INFO 18 --- [-instance.key-0] org.cloudfoundry.security.FileWatcher : Start watching /etc/cf-instance-credentials/instance.key
2019-09-26T17:51:09.585+07:00 [APP/PROC/WEB/0] [OUT] 2019-09-26 10:51:09.585 INFO 18 --- [ main] o.c.s.FileWatchingX509ExtendedKeyManager : Initialized KeyManager for /etc/cf-instance-credentials/instance.key and /etc/cf-instance-credentials/instance.crt
2019-09-26T17:51:11.629+07:00 [APP/PROC/WEB/0] [OUT] 2019-09-26 10:51:11.629 INFO 18 --- [ main] c.c.c.ConfigServicePropertySourceLocator : Located environment: name=be-customer-management-development, generic-development, profiles=[cloud,development], label=null, version=1d78f7db2bedb1e0709ad852d76819406bec9fa5, state=null
2019-09-26T17:51:11.630+07:00 [APP/PROC/WEB/0] [OUT] 2019-09-26 10:51:11.630 INFO 18 --- [ main] b.c.PropertySourceBootstrapConfiguration : Located property source: CompositePropertySource {name='configService', propertySources=[MapPropertySource {name='configClient'}, MapPropertySource {name='http://gitlab.difinite.com/bombardier/config-repository.git/generic-development.properties'}, MapPropertySource {name='http://gitlab.difinite.com/bombardier/config-repository.git/be-customer-management-development.properties'}]}
2019-09-26T17:51:11.712+07:00 [APP/PROC/WEB/0] [OUT] 2019-09-26 10:51:11.711 INFO 18 --- [ main] pertySourceApplicationContextInitializer : 'cloud' property source added
2019-09-26T17:51:11.712+07:00 [APP/PROC/WEB/0] [OUT] 2019-09-26 10:51:11.712 INFO 18 --- [ main] nfigurationApplicationContextInitializer : Reconfiguration enabled
2019-09-26T17:51:11.727+07:00 [APP/PROC/WEB/0] [OUT] 2019-09-26 10:51:11.726 INFO 18 --- [ main] c.l.u.BeCustomerManagementApplication : The following profiles are active: cloud,development
2019-09-26T17:51:16.811+07:00 [APP/PROC/WEB/0] [OUT] 2019-09-26 10:51:16.810 INFO 18 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=a89f4659-c9fe-3ba4-8c12-e063dff6a865
2019-09-26T17:51:17.241+07:00 [APP/PROC/WEB/0] [OUT] 2019-09-26 10:51:17.241 INFO 18 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$870dc353] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-09-26T17:51:17.376+07:00 [APP/PROC/WEB/0] [OUT] 2019-09-26 10:51:17.375 INFO 18 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.security.config.annotation.configuration.ObjectPostProcessorConfiguration' of type [org.springframework.security.config.annotation.configuration.ObjectPostProcessorConfiguration$$EnhancerBySpringCGLIB$$1fbb8b8d] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-09-26T17:51:17.409+07:00 [APP/PROC/WEB/0] [OUT] 2019-09-26 10:51:17.408 INFO 18 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'objectPostProcessor' of type [org.springframework.security.config.annotation.configuration.AutowireBeanFactoryObjectPostProcessor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-09-26T17:51:17.413+07:00 [APP/PROC/WEB/0] [OUT] 2019-09-26 10:51:17.412 INFO 18 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler@24959ca4' of type [org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-09-26T17:51:17.418+07:00 [APP/PROC/WEB/0] [OUT] 2019-09-26 10:51:17.417 INFO 18 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.security.config.annotation.method.configuration.GlobalMethodSecurityConfiguration' of type [org.springframework.security.config.annotation.method.configuration.GlobalMethodSecurityConfiguration$$EnhancerBySpringCGLIB$$44902e3f] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-09-26T17:51:17.429+07:00 [APP/PROC/WEB/0] [OUT] 2019-09-26 10:51:17.428 INFO 18 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'methodSecurityMetadataSource' of type [org.springframework.security.access.method.DelegatingMethodSecurityMetadataSource] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-09-26T17:51:17.455+07:00 [APP/PROC/WEB/0] [OUT] 2019-09-26 10:51:17.454 INFO 18 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$a327c650] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-09-26T17:51:18.386+07:00 [APP/PROC/WEB/0] [OUT] 2019-09-26 10:51:18.386 INFO 18 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8202 (http)
2019-09-26T17:51:18.642+07:00 [APP/PROC/WEB/0] [OUT] 2019-09-26 10:51:18.642 INFO 18 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2019-09-26T17:51:18.642+07:00 [APP/PROC/WEB/0] [OUT] 2019-09-26 10:51:18.642 INFO 18 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.16]
2019-09-26T17:51:18.680+07:00 [APP/PROC/WEB/0] [OUT] 2019-09-26 10:51:18.679 INFO 18 --- [ main] o.a.catalina.core.AprLifecycleListener : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib]
2019-09-26T17:51:18.981+07:00 [APP/PROC/WEB/0] [OUT] 2019-09-26 10:51:18.981 INFO 18 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2019-09-26T17:51:18.982+07:00 [APP/PROC/WEB/0] [OUT] 2019-09-26 10:51:18.982 INFO 18 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 7170 ms
2019-09-26T17:51:20.495+07:00 [APP/PROC/WEB/0] [OUT] 2019-09-26 10:51:20.494 INFO 18 --- [ main] ContainerTrustManagerFactory$PKIXFactory : Adding System Trust Manager
2019-09-26T17:51:20.686+07:00 [APP/PROC/WEB/0] [OUT] 2019-09-26 10:51:20.685 INFO 18 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService
2019-09-26T17:51:20.689+07:00 [APP/PROC/WEB/0] [OUT] 2019-09-26 10:51:20.688 INFO 18 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'asyncExecutor'
2019-09-26T17:51:20.803+07:00 [APP/PROC/WEB/0] [OUT] 2019-09-26 10:51:20.745 WARN 18 --- [ main] c.n.c.sources.URLConfigurationSource : No URLs will be polled as dynamic configuration sources.
2019-09-26T17:51:20.808+07:00 [APP/PROC/WEB/0] [OUT] 2019-09-26 10:51:20.807 INFO 18 --- [ main] c.n.c.sources.URLConfigurationSource : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
2019-09-26T17:51:20.833+07:00 [APP/PROC/WEB/0] [OUT] 2019-09-26 10:51:20.833 WARN 18 --- [ main] c.n.c.sources.URLConfigurationSource : No URLs will be polled as dynamic configuration sources.
2019-09-26T17:51:20.834+07:00 [APP/PROC/WEB/0] [OUT] 2019-09-26 10:51:20.833 INFO 18 --- [ main] c.n.c.sources.URLConfigurationSource : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
2019-09-26T17:51:22.127+07:00 [APP/PROC/WEB/0] [OUT] 2019-09-26 10:51:22.127 INFO 18 --- [ main] .s.s.UserDetailsServiceAutoConfiguration :
2019-09-26T17:51:22.127+07:00 [APP/PROC/WEB/0] [OUT] Using generated security password: 00b3eb29-dd56-4666-8d15-f2bfbdfc0c5e
2019-09-26T17:51:22.636+07:00 [APP/PROC/WEB/0] [OUT] 2019-09-26 10:51:22.636 INFO 18 --- [ main] o.s.s.web.DefaultSecurityFilterChain : Creating filter chain: any request, [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@3c9c0d96, org.springframework.security.web.context.SecurityContextPersistenceFilter@5812f68b, org.springframework.security.web.header.HeaderWriterFilter@1608bcbd, org.springframework.security.web.authentication.logout.LogoutFilter@2f16c6b3, org.springframework.security.oauth2.provider.authentication.OAuth2AuthenticationProcessingFilter@2766ca9d, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@3c7c886c, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@6b88ca8c, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@3a4621bd, org.springframework.security.web.session.SessionManagementFilter@29ca3d04, org.springframework.security.web.access.ExceptionTranslationFilter@6f63b475, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@73194df]
2019-09-26T17:51:23.594+07:00 [APP/PROC/WEB/0] [OUT] 2019-09-26 10:51:23.594 INFO 18 --- [ main] o.s.c.n.eureka.InstanceInfoFactory : Setting initial instance status as: STARTING
2019-09-26T17:51:23.715+07:00 [APP/PROC/WEB/0] [OUT] 2019-09-26 10:51:23.712 INFO 18 --- [ main] com.netflix.discovery.DiscoveryClient : Initializing Eureka in region us-east-1
2019-09-26T17:51:23.715+07:00 [APP/PROC/WEB/0] [OUT] 2019-09-26 10:51:23.715 INFO 18 --- [ main] com.netflix.discovery.DiscoveryClient : Client configured to neither register nor query for data.
2019-09-26T17:51:23.752+07:00 [APP/PROC/WEB/0] [OUT] 2019-09-26 10:51:23.752 INFO 18 --- [ main] com.netflix.discovery.DiscoveryClient : Discovery Client initialized at timestamp 1569495083746 with initial instances count: 0
2019-09-26T17:51:23.772+07:00 [APP/PROC/WEB/0] [OUT] 2019-09-26 10:51:23.772 INFO 18 --- [ main] o.s.c.n.e.s.EurekaServiceRegistry : Registering application BE-CUSTOMER-MANAGEMENT-TESTING with eureka with status UP
2019-09-26T17:51:23.981+07:00 [APP/PROC/WEB/0] [OUT] 2019-09-26 10:51:23.981 INFO 18 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8202 (http) with context path ''
2019-09-26T17:51:23.982+07:00 [APP/PROC/WEB/0] [OUT] 2019-09-26 10:51:23.982 INFO 18 --- [ main] .s.c.n.e.s.EurekaAutoServiceRegistration : Updating port to 8202
2019-09-26T17:51:23.986+07:00 [APP/PROC/WEB/0] [OUT] 2019-09-26 10:51:23.985 INFO 18 --- [ main] c.l.u.BeCustomerManagementApplication : Started BeCustomerManagementApplication in 19.976 seconds (JVM running for 21.949)
2019-09-26T17:52:02.056+07:00 [HEALTH/0] [ERR] Failed to make TCP connection to port 8080: connection refused
2019-09-26T17:52:02.056+07:00 [CELL/0] [ERR] Timed out after 1m0s: health check never passed.
2019-09-26T17:52:02.060+07:00 [CELL/SSHD/0] [OUT] Exit status 0
2019-09-26T17:52:02.066+07:00 [APP/PROC/WEB/0] [OUT] 2019-09-26 10:52:02.066 INFO 18 --- [ Thread-12] o.s.c.n.e.s.EurekaServiceRegistry : Unregistering application BE-CUSTOMER-MANAGEMENT-TESTING with eureka with status DOWN
2019-09-26T17:52:02.087+07:00 [APP/PROC/WEB/0] [OUT] 2019-09-26 10:52:02.087 INFO 18 --- [ Thread-12] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'asyncExecutor'
2019-09-26T17:52:02.092+07:00 [APP/PROC/WEB/0] [OUT] 2019-09-26 10:52:02.092 INFO 18 --- [ Thread-12] com.netflix.discovery.DiscoveryClient : Shutting down DiscoveryClient ...
2019-09-26T17:52:02.092+07:00 [APP/PROC/WEB/0] [OUT] 2019-09-26 10:52:02.092 INFO 18 --- [ Thread-12] com.netflix.discovery.DiscoveryClient : Completed shut down of DiscoveryClient
2019-09-26T17:52:02.516+07:00 [APP/PROC/WEB/0] [OUT] Exit status 143
2019-09-26T17:52:08.348+07:00 [CELL/0] [OUT] Cell e9fa9dcc-6c6e-4cd4-97cd-5781aa4c64e6 stopping instance 1f1190f4-7f86-40c3-7e68-00b0
2019-09-26T17:52:08.348+07:00 [CELL/0] [OUT] Cell e9fa9dcc-6c6e-4cd4-97cd-5781aa4c64e6 destroying container for instance 1f1190f4-7f86-40c3-7e68-00b0
2019-09-26T17:52:08.381+07:00 [API/19] [OUT] Process has crashed with type: "web"
2019-09-26T17:52:08.400+07:00 [API/19] [OUT] App instance exited with guid 80895621-4fa9-4603-bbf2-002d283e226f payload: {"instance"=>"1f1190f4-7f86-40c3-7e68-00b0", "index"=>0, "cell_id"=>"e9fa9dcc-6c6e-4cd4-97cd-5781aa4c64e6", "reason"=>"CRASHED", "exit_description"=>"Instance never healthy after 1m0s: Failed to make TCP connection to port 8080: connection refused", "crash_count"=>3, "crash_timestamp"=>1569495128338465796, "version"=>"6e71e5bc-4ee7-428d-98ac-ec7066b22a9f"}
2019-09-26T17:52:08.540+07:00 [PROXY/0] [OUT] Exit status 137
2019-09-26T17:52:08.932+07:00 [CELL/0] [OUT] Cell e9fa9dcc-6c6e-4cd4-97cd-5781aa4c64e6 successfully destroyed container for instance 1f1190f4-7f86-40c3-7e68-00b0
2019-09-26T17:52:44.720+07:00 [API/5] [OUT] Updating process: "web"
2019-09-26T17:52:51.531+07:00 [CELL/0] [OUT] Cell ccbb6c0b-fe8a-4497-bbda-4c5b42a369bf creating container for instance 06570bc1-ee86-4397-6ff2-ed2c

bootstrap.properties

spring.application.name=be-customer-management-testing
spring.profiles.active=development
spring.cloud.config.uri=https://myUrlGlobalCOnfigInPivotal
spring.cloud.config.name=name1, name2
spring.cloud.config.fail-fast=true
management.endpoints.web.exposure.include=*

application.yml

eureka:
client:
serviceUrl:
defaultZone: ${vcap.services.eureka-service.credentials.uri:http://localhost:8761}/eureka/
registerWithEureka: false
fetchRegistry: false

应用程序云.properties

eureka.instance.hostname=${vcap.application.uris[0]}
eureka.instance.non-secure-port=80
eureka.instance.metadata-map.instanceId=${vcap.application.instance_id}

抱歉迟回复和更新

最佳答案

您的问题是 Tomcat 在错误的端口上启动。从你的日志中...

2019-09-26T17:51:18.386+07:00 [APP/PROC/WEB/0] [OUT] 2019-09-26 10:51:18.386 INFO 18 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8202 (http)

很明显,它是在端口 8202 上启动的。这会破坏平台运行状况检查,因为平台要求您在端口 8080 上启动应用程序。由于应用程序没有监听所请求的端口,因此运行状况检查无法成功完成,并且Cloud Foundry 必须假设您的应用程序从未启动,因此它会尝试重新启动应用程序,希望它下次能够正常工作。不幸的是,这是一个配置错误,因此它永远不会通过重新启动来修复,因此会永远循环。

至于为什么您的应用程序在端口 8202 上启动,目前尚不清楚。我没有看到您指定的 application.yml 中设置了该设置,但有可能在其他地方设置了它。

对于 Spring Boot,您正在寻找正在设置的 server.portIt can be set in a number of places including application.properties, application.yml, as an env variable or system property 。需要将其设置为 8080,或者更好的是 $PORT 环境变量,该变量由 Cloud Foundry 设置并包含您的应用程序应监听的预期端口。 (附注,Java 构建包应该为您配置此项,除非您覆盖启动命令或执行某些操作来更改其默认行为)。

当 Tomcat 报告它已在端口 8080 上启动并且运行状况检查通过时,您就会知道这是正确的。

希望有帮助!

关于java - 推送到关键时无法与端口 8080 建立 TCP 连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58050476/

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