I'm getting below error when I make resttemplate call as below. To me it looks like random generated hostname is not accessible.
I use pcfdev-v0.30.2+PCF1.11.0-windows , pcfdev-v1.2.0-windows. spring-boot.2.1.3.
// Get movie details MovieDetails movieDetails = restTemplate.getForObject("http://movie-details-service/jpamovies/" + movieId, MovieDetails.class);
"message": "I/O error on GET request for \"http://movie-details-service/jpamovies/2\": 7c6b7bdc-36ca-4b0f-77d9-f2f2; nested exception is java.net.UnknownHostException: 7c6b7bdc-36ca-4b0f-77d9-f2f2",
I'm having Eureka server registration as below.
| Application | AMIs | Availability Zones | Status |
|---|---|---|---|
| MOVIE-CATALOG-SERVICE | n/a (1) | (1) | UP (1) - bdd136c3-c3e6-4333-4840-fcd0 |
| MOVIE-DETAILS-SERVICE | n/a (1) | (1) | UP (1) - 7c6b7bdc-36ca-4b0f-77d9-f2f2 |
Please help to resolve the issue.
Comment From: ryanjbaxter
Ribbon does not seem to know about MOVIE-DETAILS-SERVICE. I can't really say why based on the information above. Are you positive the application is connecting to Eureka and getting the list of services? There should be logs indicating that is happening.
Comment From: mkpraveen
Hello Ryan, Thanks for responding to the issue.
Below are logs I could see when I hit a service that uses movie-details-service. Attaching log file if that helps you to direct me to what is wrong.
2019-06-11 08:14:30.688 INFO 27 --- [nio-8080-exec-4] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
2019-06-11 08:14:30.688 INFO 27 --- [nio-8080-exec-4] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2019-06-11 08:14:30.700 INFO 27 --- [nio-8080-exec-4] o.s.web.servlet.DispatcherServlet : Completed initialization in 12 ms
2019-06-11 08:14:30.997 INFO 27 --- [nio-8080-exec-4] ContainerTrustManagerFactory$PKIXFactory : Adding System Trust Manager
2019-06-11 08:14:31.050 INFO 27 --- [nio-8080-exec-4] c.netflix.config.ChainedDynamicProperty : Flipping property: movie-details-service.ribbon.ActiveConnectionsLimit to use NEXT property: niws.loadbalancer.availabilityFilteringRule.activeConnectionsLimit = 2147483647
2019-06-11 08:14:31.084 INFO 27 --- [nio-8080-exec-4] c.n.u.concurrent.ShutdownEnabledTimer : Shutdown hook installed for: NFLoadBalancer-PingTimer-movie-details-service
2019-06-11 08:14:31.085 INFO 27 --- [nio-8080-exec-4] c.netflix.loadbalancer.BaseLoadBalancer : Client: movie-details-service instantiated a LoadBalancer: DynamicServerListLoadBalancer:{NFLoadBalancer:name=movie-details-service,current list of Servers=[],Load balancer stats=Zone stats: {},Server stats: []}ServerList:null
2019-06-11 08:14:31.098 INFO 27 --- [nio-8080-exec-4] c.n.l.DynamicServerListLoadBalancer : Using serverListUpdater PollingServerListUpdater
2019-06-11 08:14:31.120 INFO 27 --- [nio-8080-exec-4] c.netflix.config.ChainedDynamicProperty : Flipping property: movie-details-service.ribbon.ActiveConnectionsLimit to use NEXT property: niws.loadbalancer.availabilityFilteringRule.activeConnectionsLimit = 2147483647
2019-06-11 08:14:31.121 INFO 27 --- [nio-8080-exec-4] c.n.l.DynamicServerListLoadBalancer : DynamicServerListLoadBalancer for client movie-details-service initialized: DynamicServerListLoadBalancer:{NFLoadBalancer:name=movie-details-service,current list of Servers=[47d92f69-9200-4d56-5176-6909:8080],Load balancer stats=Zone stats: {defaultzone=[Zone:defaultzone; Instance count:1; Active connections count: 0; Circuit breaker tripped count: 0; Active connections per server: 0.0;]
},Server stats: [[Server:47d92f69-9200-4d56-5176-6909:8080; Zone:defaultZone; Total Requests:0; Successive connection failure:0; Total blackout seconds:0; Last connection made:Thu Jan 01 00:00:00 UTC 1970; First connection made: Thu Jan 01 00:00:00 UTC 1970; Active Connections:0; total failure count in last (1000) msecs:0; average resp time:0.0; 90 percentile resp time:0.0; 95 percentile resp time:0.0; min resp time:0.0; max resp time:0.0; stddev resp time:0.0]
]}ServerList:org.springframework.cloud.netflix.ribbon.eureka.DomainExtractingServerList@483784b5
2019-06-11 08:14:31.414 ERROR 27 --- [nio-8080-exec-4] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.web.client.ResourceAccessException: I/O error on GET request for "http://movie-details-service/jpamovies/2": 47d92f69-9200-4d56-5176-6909; nested exception is java.net.UnknownHostException: 47d92f69-9200-4d56-5176-6909] with root cause
java.net.UnknownHostException: 47d92f69-9200-4d56-5176-6909
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:184) ~[na:1.8.0_192]
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~[na:1.8.0_192]
at java.net.Socket.connect(Socket.java:589) ~[na:1.8.0_192]
at java.net.Socket.connect(Socket.java:538) ~[na:1.8.0_192]
at sun.net.NetworkClient.doConnect(NetworkClient.java:180) ~[na:1.8.0_192]
at sun.net.www.http.HttpClient.openServer(HttpClient.java:463) ~[na:1.8.0_192]
at sun.net.www.http.HttpClient.openServer(HttpClient.java:558) ~[na:1.8.0_192]
at sun.net.www.http.HttpClient.<init>(HttpClient.java:242) ~[na:1.8.0_192]
at sun.net.www.http.HttpClient.New(HttpClient.java:339) ~[na:1.8.0_192]
Comment From: ryanjbaxter
Maybe it is something with the way the movies-details-service, Ribbon thinks the hostname is 47d92f69-9200-4d56-5176-6909, which obviously is either not right or not reachable.
Comment From: mkpraveen
I see it is able to get list of servers from Eureka where server is registered with Random hostname. Please see log below.
As mentioned earlier, I'm running PCFDEV in Windows 10 using Hyper-V. Is there a way to have applications register with ip address in Eureka? I'm missing any configuration that is causing this ?
2019-06-11 08:14:31.121 INFO 27 --- [nio-8080-exec-4] c.n.l.DynamicServerListLoadBalancer : DynamicServerListLoadBalancer for client movie-details-service initialized: DynamicServerListLoadBalancer:{NFLoadBalancer:name=movie-details-service,current list of Servers=[47d92f69-9200-4d56-5176-6909:8080],Load balancer stats=Zone stats: {defaultzone=[Zone:defaultzone; Instance count:1; Active connections count: 0; Circuit breaker tripped count: 0; Active connections per server: 0.0;]
Comment From: spencergibb
Eureka doesn't generate random hostnames. You probably need to tell eureka to use the ip address rather than hostname.
Comment From: spring-projects-issues
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Comment From: mkpraveen
I have added below properties at Eureka, still gets connection refused on REST call.
Server:
server.port=8761 spring.application.name=eureka-service
Eureka server
eureka.client.register-with-eureka=false eureka.client.fetch-registry=false
logging.level.com.netflix.eureka=OFF logging.level.com.netflix.discovery=OFF
eureka.client.serviceUrl.defaultZone=http://eureka-server.dev.cfdev.sh
eureka.instance.prefer-ip-address=true
Client:
eureka: client: serviceUrl: defaultZone: http://eureka-server.dev.cfdev.sh/eureka/ instance: prefer-ip-address: true
Eureka Instances
| Application | AMIs | Availability Zones | Status |
|---|---|---|---|
| MOVIE-CATALOG-SERVICE | n/a (1) | (1) | UP (1) - 4856f350-28db-4ef5-70fd-c99d |
| MOVIE-DETAILS-SERVICE | n/a (1) | (1) | UP (1) - d61a68f3-d536-4780-75c5-61fa |
| RATING-DETAILS-SERVICE | n/a (1) | (1) | UP (1) - 2a1036ab-59b9-462d-7bc9-456b |
| USER-DETAILS-SERVICE | n/a (1) | (1) | UP (1) - b4001649-d11c-488c-5b2e-8aa6 |
New Stack Trace
2019-06-24 05:06:45.154 INFO 22 --- [nio-8080-exec-5] c.netflix.config.ChainedDynamicProperty : Flipping property: movie-details-service.ribbon.ActiveConnectionsLimit to use NEXT property: niws.loadbalancer.availabilityFilteringRule.activeConnectionsLimit = 2147483647 2019-06-24 05:06:45.156 INFO 22 --- [nio-8080-exec-5] c.n.l.DynamicServerListLoadBalancer : DynamicServerListLoadBalancer for client movie-details-service initialized: DynamicServerListLoadBalancer:{NFLoadBalancer:name=movie-details-service,current list of Servers=[10.255.114.12:8080],Load balancer stats=Zone stats: {defaultzone=[Zone:defaultzone; Instance count:1; Active connections count: 0; Circuit breaker tripped count: 0; Active connections per server: 0.0;] },Server stats: [[Server:10.255.114.12:8080; Zone:defaultZone; Total Requests:0; Successive connection failure:0; Total blackout seconds:0; Last connection made:Thu Jan 01 00:00:00 UTC 1970; First connection made: Thu Jan 01 00:00:00 UTC 1970; Active Connections:0; total failure count in last (1000) msecs:0; average resp time:0.0; 90 percentile resp time:0.0; 95 percentile resp time:0.0; min resp time:0.0; max resp time:0.0; stddev resp time:0.0] ]}ServerList:org.springframework.cloud.netflix.ribbon.eureka.DomainExtractingServerList@4b01c398 2019-06-24 05:06:46.132 INFO 22 --- [erListUpdater-0] c.netflix.config.ChainedDynamicProperty : Flipping property: movie-details-service.ribbon.ActiveConnectionsLimit to use NEXT property: niws.loadbalancer.availabilityFilteringRule.activeConnectionsLimit = 2147483647 2019-06-24 05:06:46.195 ERROR 22 --- [nio-8080-exec-5] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.web.client.ResourceAccessException: I/O error on GET request for "http://movie-details-service/jpamovies/2": Connection refused (Connection refused); nested exception is java.net.ConnectException: Connection refused (Connection refused)] with root cause java.net.ConnectException: Connection refused (Connection refused) at java.net.PlainSocketImpl.socketConnect(Native Method) ~[na:1.8.0_192] at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) ~[na:1.8.0_192]
Comment From: ryanjbaxter
Please learn how to format code on GitHub.
What is the output of /eureka/apps?
Comment From: spring-projects-issues
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Comment From: spring-projects-issues
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.
Comment From: akyhcs
@mkpraveen, have u solved the issue i am facing same issue.
Comment From: Csk314
@mkpraveen Can you pls share how you solved this, I'm getting same issue.
Comment From: RogCode
Just add @LoadBalanced annotation
@Configuration public class RestTemplateConfiguration { @Bean @LoadBalanced public RestTemplate registerRestTemplate() { return new RestTemplate(); } }
Comment From: shwetanknaveen
@RogCode I'm already doing that (added LoadBalanced) from the very start still I'm my service instance is not found!!