title: Docker swarm : org.apache.kafka.common.errors.TimeoutException: Timed out waiting for a node assignment
body: <p>I am trying to containerize a java server application which uses <strong>kafka</strong>. I observed this behavior,</p>
  
  <p><strong>Case 1 : Running as a single container uses bridge network</strong></p>
  
  <p>In this case it works well. So no problem.</p>
  
  <p><strong>Case 2 : Running as a single service uses overlay network (Swarm mode)</strong></p>
  
  <p>In this case, I got <code>org.apache.kafka.common.errors.TimeoutException</code> because of this unsuccessful connection,</p>
  
  <pre><code>WARN [2019-12-06T14:05:44,668] RequestSendThread: warn(): [Controller-0-to-broker-0-send-thread]: Controller 0's connection to broker 10.255.3.64:10101 (id: 0 rack: null) was unsuccessful
  java.net.SocketTimeoutException: Failed to connect within 30000 ms
          at kafka.controller.RequestSendThread.brokerReady(ControllerChannelManager.scala:270) [kafka_2.12-1.0.0.jar:?]
          at kafka.controller.RequestSendThread.doWork(ControllerChannelManager.scala:223) [kafka_2.12-1.0.0.jar:?]
          at kafka.utils.ShutdownableThread.run(ShutdownableThread.scala:64) [kafka_2.12-1.0.0.jar:?]
  </code></pre>
  
  <p>I don't know much about <strong>kafka</strong> and can't understand <strong>How overlay network affects the kafka process while it works well in bridge network</strong> ?</p>
  
  <p><strong>Edit 1:</strong></p>
  
  <p>Almost found the problem... In docker swarm mode, container have <strong>two ip address</strong> because of the two interfaces <code>bridge</code> and <code>overlay</code>. The ips are <code>endpoint:172.19.0.3, 10.255.3.65</code>.</p>
  
  <p>While trying to connect to the container (inside from the same container),</p>
  
  <p><strong>Bridge I/F :</strong> <code>172.19.0.3 : 10101</code> - can connect. means <code>telent 172.19.0.3 10101</code> works.
  <strong>Overlay I/F :</strong><code>10.155.3.65 : 10101</code> - can't connect to the port, but can ping works.</p>
  
  <p>The virtual ip <code>10.155.3.65</code> which is used by kafka that makes <code>TimeoutException</code>.</p>
  
  <p><strong>Cannot connect to the localhost port while using overlay ip (but can ping). Why this scenario happens ?</strong></p>