-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
getURI() in EurekaServiceInstance misses custom contextPath. #737
Comments
We've not extended eureka to know about an instances context path yet. |
Hi, When will it be available to download? |
@ofbizbrazil it hasn't been done, until it has, it won't be available to download. |
My applications have context-path at uri, is there any workaround until this is done? |
Hi @spencergibb, of course i saw that comment, but my doubt is how to apply this 'locally shadowing' mentioned in there. I guess the spring package was patched to overwrite the class EurekaDiscoveryClient. Do you know how to do it? |
Hi @ofbizbrazil, (as a quick hack) just copy the Cheers, |
That's I was afraid of, doing a patch into my project to handle the class EurekaDiscoveryClient. |
Yep - same here - I just used this to verify what a potential solution might be... ;-) |
What's the use case? Why do you need this? |
Nowadays we are limiting an application to only use a root context, and if I want to change the context-path to a different name, EurekaDiscoveryClient simply does work and nobody will know about it. So, in my opinion that's a critical issue, taking in mind Spring Netflix only works for a specific URI. |
I guess I think it's strange that you would change the context of a service and not expect clients to change. This has been marked as |
My micro-service uses a custom context-path and the clients which uses it really works fine. The issue here is EurekaDiscoveryClient does support context-path when the method getUri() builds the URI. There should be the methods getContextPath or getHomePageUrl in EurekaServiceInstance to allow this resource. |
@spencergibb I wanted to do a fix on this fella the other day
So, I think if it is decided to change the EurekaDiscoveryClient.getUri, to modify in spring-cloud-config the homePage |
Hi, |
is ther any news about this matter? |
Is this still the case? I´m running in to this problem at the moment using the default ribbon configuration. |
I am curious. Has there been any update to this issue? Thanks! |
No update. It's not high on our priorities since it can be done with properties. Pull requests welcome. |
Use case for this issue: We are looking for a way that we can register the old version with context root '/myapp' and the new version with '/' as context root. |
@cbos the exact same problem,any suggestions for now? |
We fixed the issue ourselves, as we did register the services ourselves to Eureka. So we added the context path as setting to the metadata. |
@cbos How did you register your service manually with custom context-path? |
We have our own client which registers the service to Eureka. With that we add teh context-path in the metadata. |
@cbos could you please provide any code snippet you used in your client to register context path? |
Hi @spencergibb, Thank you for your insights! So in my case we are running multiple services in a single weblogic container and they all need different context paths. The port number is also fixed, so that's not an option. You mentioned that this can be changed with properties? I have looked into the home page url properties and tried every combination I could think of with no luck. |
Hi @spencergibb, I too face the same issue as @silentFred . It would be great if you could provide us some insights on this issue. I have tried the following as of now and it has failed:
The context path is not added to the hystrix stream url, it's still http://host:port/hystrix.stream, it isn't http://host:port/context-path/hystrix.stream As @silentFred addressed, the host and the port are same for all the microservice while the context paths are different. Note: The microservice, turbine-app are deployed in weblogic 12c and the eureka server is running in tomcat. |
looked at @thomasdarimont Hack!!! wondering if that can be included in source code and published as new jar files |
Part of the issue is this goes beyond just eureka and would have to be changed in other discovery clients as well. |
@spencergibb yep! We ended up abusing the homePageUrl config to cater for contexts in Zuul and other clients that use ribbon. Not all that pretty =( With some inspiration from @thomasdarimont I managed to put together something that worked for me: http://webler.co.za/blog/spring-cloud-web-context-root-aware-zuul-eureka-service-calls-code-bit/ |
It's all or nothing and doing "all" is a big effort. |
@silentFred when I go to the link I get 403 error. |
@silentFred Can you please check for the Autowired block in http://webler.co.za/blog/spring-cloud-web-context-root-aware-zuul-eureka-service-calls-code-bit/ ? I am getting error in that |
@rax215 @kasibkismath the pages load fine for me...
|
@silentFred Sorry for the confusion, I meant Autowired block of "ContextAwareRibbonRoutingFilter" class.
The semicolon after RibbonCommandFactory<?>;, is it correct? and the attributes in super() are throwing error for me. |
@rax215 It looks like a typo. Remove that semicolon. Not too sure why super() is throwing errors |
@kasibkismath for the context-path with Turbine issue you have raised, PFB my finding and the fix worked for me.
|
@fahimfarookme it works perfectly as expected. There are few gotchas as you have mentioned, however, what is the overall impact since we are extending EurekaInstanceDiscovery, which is a class of spring-cloud-netflix-turbine, considering the fact that at a later point of time we will be upgrading netflix-turbine as well. |
@kasibkismath This solution is only for the Turbine issue you have raised. This is the standard way of providing custom discovery mechanism for Turbine. Will have upgradability concern only for Turbine, however safer than extending Eureka server or client related classes - if everything else works fine for you. |
Is anyone already working on this issue? I don't want to step on toes. |
I resolved this error with following eureka: appname: TestHZAppinstanceId: TestHZApp:${spring.application.instance-id:${random.value}}
zone: primary # This is needed for the load balancerprofile: ${spring.profiles.active}version: ${info.project.version}
|
I don't know if this code will still work on later version but give this a
shot:
http://webler.co.za/blog/spring-cloud-web-context-root-aware-zuul-eureka-service-calls-code-bit/
…On Sat, 30 Dec 2017 at 01:38 dsushil2000 ***@***.***> wrote:
I have requirement to publish Boot Microservices with context path. How we
can solve the problem? Eureka does not register the App with Context Path
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#737 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABenf5974A6boiGaumxxXYYpi0jTqIILks5tFXfegaJpZM4G4gMt>
.
|
I think that there is still a lot of interest in this feature and I also want to present a problem that we are currently facing. Example: Dynamic microservice architecture using TLS/SSL secured endpoints only with no need for an wildcard certificate. Solutions:
Downside of context-path based routing with current Spring Cloud (Zuul, Eureka) implementation:
=> Support for context paths would really help here Downside SANs: |
@jrauschenbusch For me, this behavior seems like a huge design bug with Spring Cloud in general (not just Eureka). One of the founding design concepts of Java Servlets, and web development in general, was the ability to be deployed anywhere under any context, and have the application behave the same. It shouldn't matter if we "make war" instead of jar, deploy as root or with a custom context, nor even if the different instances have different contexts. This was the main appeal of Servlets, and the reason why so many companies (many on windows) decided to adopt it. |
Has there been any update on this issue? I am facing the same issues mentioned above. |
I have a workaround for the edgeware release train if you are looking to
expose your services via zuul. For service to service calls we've had to
add the context to the service name in our load balanced clients ie.
http://some-service-name/some-context
There is a way you can override ribbon behaviour to take care of this for
you that i have lying around somewhere if anyone is interested.
…On Wed, 10 Oct 2018, 06:36 Christopher Hagler, ***@***.***> wrote:
Has there been any update on this issue? I am facing the same issues
mentioned above.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#737 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABenf6H3VTIxTGWjLKBQKUIDPE9_gR3Oks5ujXkpgaJpZM4G4gMt>
.
|
This is something we've avoided in the past and are not looking to implement this at this time. |
I just bumped into this bu^H^Hfeature today. Is there a reason why this couldn't be fixed by using the specified homePageUrl/homePageUrlPath in Eureka? Would this break some other functionality? Most of our services unfortunately have a context path and are not served on '/', so this makes it a little harder to use the default Eureka client (I would rather use the default instead of supporting my own). |
We've decided as a team not to support this. |
You can pass the custom context-path into the instance metadata-map
and access the value by calling
|
I have several Spring Boot Apps with REST endpoints with custom
server.contextPath
'swhich use
@EnableDiscoveryClient
to register themselves in the eureka service registry.The applications are registered with eureka at startup and later queried
by a management application. I just found out that the
URI
s returned byonly contain scheme,hostname and port but no custom context-path.
The
URI
s were returned bydiscoveryClient.getInstances(serviceId)
wherediscoveryClient
is anEurekaDiscoveryClient
.The URI one gets via
looks like:
The proper URI would be:
I fixed tested this by locally shadowing the
org.springframework.cloud.netflix.eureka.EurekaDiscoveryClient
and replacing the body of theURI getUri()
method with:With that adjustment the
org.springframework.cloud.client.ServiceInstance
that I got backreturned the proper service
URI
s.I think the op of the issue #500 has the same problem.
Another Problem was that I needed to explicitly declare a
in order to get custom eureka instance settings in an
applications.yml
file taken into account atall but I guess that's for another issue ;-)
The text was updated successfully, but these errors were encountered: