-
Notifications
You must be signed in to change notification settings - Fork 540
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
Service not registering in Consul when packaged in war and deployed to external Tomcat #302
Comments
From gitter he mentioned using boot 1.5.2 and Dalston.RELEASE. See #173 |
@spencergibb , |
No |
@spencergibb ,thanks! |
No one is currently working on this. |
@whitneyh
|
@ask4gilles Can you point me to what I am missing? |
@ask4gilles @bdpeterson Did you implement any workarounds? |
@vrnroman I was able to generally solve it for my need. I created a Configuration class that was ApplicationContextAware. The basic code is below:
This assumes that you still set the server.port property (and this isn't normally used with deployed tomcat) |
Hi all, I am facing the same issue and I am able to register my service with the consul with the above code that @bdpeterson suggested. Thanks @bdpeterson. I am able to see my service in the consul UI but the Application level health check is Failing. Can anyone give me an insight into why it's failing? Also If I deploying the Application as a WAR on a Tomcat, should I have server.port property in the application.properties? |
@bhagathk Technically, no, you don't need the server.port property in the application.properties. However, the code above requires server.port or some other property to set the registration port. With your health check failing, confirm that you can connect to the health endpoint yourself. Often, it might be secured or otherwise rejecting connections. Beyond that, more details would be needed to identify why it is failing. |
Thanks for the quick response @bdpeterson. When I run the application using the embedded tomcat the application level health check is not failing, Only when I deploy the application as a War then the health check is failing? |
Check your application context. Deployed vs embedded default differently. |
I am seeing the below on the console application level health check. "net/http: request canceled (Client.Timeout exceeded while awaiting headers)" I myself not able to hit the health endpoint. I tried to hit the health endpoint from Postman and it says couldn't get any response? |
I am able to get the application health check to work by changing the Default Health Url that Consul hits every 10 seconds to check the health of the service. I used sping.cloud.consul.discovery.healthCheckUrl to pass the Custom Health Url. |
@bdpeterson Thank you for your solution :) How you define @AutoConfigurationAfter ? |
In Finchley.SR2 I have to use |
FYI for other people looking at this for recent Spring Cloud versions, per @spencergibb at https://stackoverflow.com/a/54156442/9589945, setting server.port and then setting spring.cloud.consul.discovery.port=${server.port} should now be the way to go. I still needed the listener to actually start the registration because ConsulAutoServiceRegistrationListener is not triggered in WAR mode. Note that "@AutoConfigurationAfter" has been changed to "@AutoConfigureAfter" So, properties:
Listener:
|
I have a Spring Cloud service that should register itself with Consul. When I start it with embedded Tomcat, this works as expected. However, when I package it as a war and deploy to an external Tomcat instance, it is not registering. There is no error or related messages in the console. It does not display the "Registering service with consul..." log message.
I have tried explicitly specifying server.port in bootstrap.yml but this does not change the behavior.
The text was updated successfully, but these errors were encountered: