title: Spring Boot with server.contextPath set vs. URL to hystrix.stream via Eureka Server
body: <p>I have Eureka Server with Turbine instance running and a few discovery clients that are connected to it. Everything works fine, but if I register a discovery client that has <code>server.contextPath</code> set, it didn't get recognized by <code>InstanceMonitor</code> and Turbine stream is not able to combine its <code>hystrix.stream</code>.</p>
  <p>This is how it looks in the logs of Eureka/Turbine server:</p>
  <pre><code>2015-02-12 06:56:23.265  INFO 1 --- [        Timer-0] c.n.t.discovery.InstanceObservable       : Hosts up:3, hosts down: 0
  2015-02-12 06:56:23.266  INFO 1 --- [        Timer-0] c.n.t.monitor.instance.InstanceMonitor   : Url for host: http://user-service:8887/hystrix.stream default
  2015-02-12 06:56:23.268 ERROR 1 --- [InstanceMonitor] c.n.t.monitor.instance.InstanceMonitor   : Could not initiate connection to host, giving up: []
  2015-02-12 06:56:23.269  WARN 1 --- [InstanceMonitor] c.n.t.monitor.instance.InstanceMonitor   : Stopping InstanceMonitor for: user-service default
  
  com.netflix.turbine.monitor.instance.InstanceMonitor$MisconfiguredHostException: []
      at com.netflix.turbine.monitor.instance.InstanceMonitor.init(InstanceMonitor.java:318)
      at com.netflix.turbine.monitor.instance.InstanceMonitor.access$100(InstanceMonitor.java:103)
      at com.netflix.turbine.monitor.instance.InstanceMonitor$2.call(InstanceMonitor.java:235)
      at com.netflix.turbine.monitor.instance.InstanceMonitor$2.call(InstanceMonitor.java:229)
      at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      at java.lang.Thread.run(Thread.java:745)
  </code></pre>
  <p>It tries to get hystrix stream from <code>http://user-service:8887/hystrix.stream</code> where the correct URL including sever.contextPath should be <code>http://user-service:8887/uaa/hystrix.stream</code></p>
  <p>The <code>application.yml</code> of that client contains:</p>
  <pre><code>server:
    port: 8887
    contextPath: /uaa
  
  security:
    ignored: /css/**,/js/**,/favicon.ico,/webjars/**
    basic:
      enabled: false
  </code></pre>
  <p><strong>My question is:</strong> should I add some additional configuration options to this user-service discovery client to register proper hystrix.stream URL location?</p>
  <p>I didn't dig into that yet, I will let you know if found something before getting answer to that question.</p>
  <h2>Current solution</h2>
  <p>There is one problem when it comes to using <code>server.contextPath</code> and <code>management.context-path</code>. When both are set, turbine stream is being served on <code>${HOST_URL}/${server.contextPath}/${management.context-path}/hystrix.stream</code>. In that case I had to drop using <code>server.contextPath</code> (I replaced it with a prefix in controllers <code>@RequestMapping</code>).</p>
  <p>Now, when you user <code>management.context-path</code>, then your hystrix.stream is being served from the URL that uses it as a prefix. In that case you have to follow Spencer's suggestion and set</p>
  <pre><code>turbine.instanceUrlSuffix=/{PUT_YOUR_MANAGEMENT_CONTEXT_PATH_HERE}/hystrix.stream
  </code></pre>
  <p>And of course this <code>management.context-path</code> must be set with the same value for all your Discovery Clients - it can be done easily with Spring Cloud Config <a href="http://cloud.spring.io/spring-cloud-config/spring-cloud-config.html" rel="nofollow noreferrer">http://cloud.spring.io/spring-cloud-config/spring-cloud-config.html</a></p>