Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot resolve service when service name starts with http #873

Closed
paulluap opened this issue Jul 3, 2023 · 1 comment
Closed

cannot resolve service when service name starts with http #873

paulluap opened this issue Jul 3, 2023 · 1 comment
Assignees
Labels
bug Something isn't working
Milestone

Comments

@paulluap
Copy link

paulluap commented Jul 3, 2023

Describe the bug
Using spring cloud openfiegn client

@FeignClient(value ="httpbin2")
public interface TestFeignClient {

    @RequestMapping(value = "/headers", method = RequestMethod.GET)
    String headers();

  • spring boot version: 2.7.13
  • spring cloud : 2021.0.7

When the fiegn client is called, the following service unavailable error occurs

feign.FeignException$ServiceUnavailable: [503] during [GET] to [null://nullhttpbin2/headers] [TestFeignClient#headers()]: [Load balancer does not contain an instance for the service nullhttpbin2]
        at feign.FeignException.serverErrorStatus(FeignException.java:256) ~[feign-core-11.10.jar:na]
        at feign.FeignException.errorStatus(FeignException.java:197) ~[feign-core-11.10.jar:na]
        at feign.FeignException.errorStatus(FeignException.java:185) ~[feign-core-11.10.jar:na]
        at feign.codec.ErrorDecoder$Default.decode(ErrorDecoder.java:92) ~[feign-core-11.10.jar:na]
        at feign.AsyncResponseHandler.handleResponse(AsyncResponseHandler.java:98) ~[feign-core-11.10.jar:na]
        at feign.SynchronousMethodHandler.executeAndDecode(SynchronousMethodHandler.java:141) ~[feign-core-11.10.jar:na]
        at feign.SynchronousMethodHandler.invoke(SynchronousMethodHandler.java:91) ~[feign-core-11.10.jar:na]
        at feign.ReflectiveFeign$FeignInvocationHandler.invoke(ReflectiveFeign.java:100) ~[feign-core-11.10.jar:na]
        at com.sun.proxy.$Proxy69.headers(Unknown Source) ~[na:na]
        at com.example.demo.TestController.feignHeaders(TestController.java:16) ~[classes/:na]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_292]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_292]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_292]

I notice this happens becuase the service name happens to start with "http",
see FeignClientFactoryBean.getTarget for the logic

It took some time to find where the invalid url is constructed. (My first attempt was to find why "ribbon.client.name" is "nullhttpbin2", then why the clientName is nullhttpbin2 ... and tried all @FeignClient annotation usage to see if I missed something). Note the ribbon part is from an old version of spring boot/cloud.

It's rare that the service name starts with http, however an error reporting in the frist place during startup will be greately helpful.

I don't know if it's worth a more appropriate handling and hence allow service name to start with "http". By the way, inspired by the spring cloud gateway get started examples, I created a service also named httpbin...

@OlgaMaciaszek OlgaMaciaszek self-assigned this Dec 4, 2023
@OlgaMaciaszek OlgaMaciaszek added bug Something isn't working and removed waiting-for-triage labels Dec 4, 2023
@OlgaMaciaszek OlgaMaciaszek moved this to In Progress in 2021.0.9 Dec 4, 2023
@OlgaMaciaszek OlgaMaciaszek moved this to In Progress in 2022.0.5 Dec 4, 2023
@OlgaMaciaszek OlgaMaciaszek moved this to In Progress in 2023.0.0 Dec 4, 2023
@OlgaMaciaszek OlgaMaciaszek added this to the 3.1.9 milestone Dec 4, 2023
@OlgaMaciaszek
Copy link
Collaborator

Hello @paulluap, thanks for reporting it. Makes sense. We'll fix it.
Btw., Spring Cloud Netflix Ribbon has been out of maintenance for many years now. Please stop using it. It can expose you to security vulnerabilities. Please use Spring Cloud LoadBalancer instead.

@github-project-automation github-project-automation bot moved this from In Progress to Done in 2021.0.9 Dec 4, 2023
@github-project-automation github-project-automation bot moved this from In Progress to Done in 2022.0.5 Dec 4, 2023
@github-project-automation github-project-automation bot moved this from In Progress to Done in 2023.0.0 Dec 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Status: Done
Status: Done
Development

No branches or pull requests

3 participants