title: Timeout connection when using Gremlin to connect to Azure cosmossDB emulator
body: <p>I'm trying have a crack at using Gremlin/Java graph mode with cosmossDB emulator and got into trouble.</p>
  <p>Emulator is all installed, and running and certificate is imported to my Java keystore (I can connect using document interface so I know that's working).</p>
  <p>The emulator web console is presently showing collections and not graphs.</p>
  <p>My simple code (in Groovy script) looks like this</p>
  <pre><code>Cluster cluster
  Client client
  
  try {
       def builder = Cluster.build()
  
          builder.addContactPoint(&quot;localhost&quot;)
          .port(8081)
          .protocol (&quot;https&quot;)
          .keyPassword(&quot;C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==&quot;)
          .enableSsl(true)
  
          cluster = builder.create()
      } catch (Exception ex) {
      ex.printStackTrace()
  
  
  }
  
  
  client = cluster.connect()
  
  String[] gremlinQueries = [
          &quot;g.V().drop()&quot;,
          &quot;g.addV('person').property('id', 'thomas').property('firstName', 'Thomas').property('age', 44)&quot;,
          &quot;g.addV('person').property('id', 'mary').property('firstName', 'Mary').property('lastName', 'Andersen').property('age', 39)&quot;,
          &quot;g.addV('person').property('id', 'ben').property('firstName', 'Ben').property('lastName', 'Miller')&quot;,
          &quot;g.addV('person').property('id', 'robin').property('firstName', 'Robin').property('lastName', 'Wakefield')&quot;,
          &quot;g.V('thomas').addE('knows').to(g.V('mary'))&quot;,
          &quot;g.V('thomas').addE('knows').to(g.V('ben'))&quot;,
          &quot;g.V('ben').addE('knows').to(g.V('robin'))&quot;,
          &quot;g.V('thomas').property('age', 44)&quot;,
          &quot;g.V().count()&quot;,
          &quot;g.V().hasLabel('person').has('age', gt(40))&quot;,
          &quot;g.V().hasLabel('person').order().by('firstName', decr)&quot;,
          &quot;g.V('thomas').outE('knows').inV().hasLabel('person')&quot;,
          &quot;g.V('thomas').outE('knows').inV().hasLabel('person').outE('knows').inV().hasLabel('person')&quot;,
          &quot;g.V('thomas').repeat(out()).until(has('id', 'robin')).path()&quot;,
          &quot;g.V('thomas').outE('knows').where(inV().has('id', 'mary')).drop()&quot;,
          &quot;g.E().count()&quot;,
          &quot;g.V('thomas').drop()&quot;
  
  ]
  
  for (gremlin in gremlinQueries) {
      ResultSet results = client.submit(gremlin);
  
      CompletableFuture&lt;List&lt;Result&gt;&gt; completableFutureResults = results.all()
      List&lt;Result&gt; resultList = completableFutureResults.get()
  
      for (Result result : resultList) {
          println(result.toString())
      }
  
  }
  </code></pre>
  <p>The builder creates and client connects when I watch in debugger, but when I try the client to submit I get following stacktrace.</p>
  <pre><code>Connected to the target VM, address: '127.0.0.1:59992', transport: 'socket'
  SLF4J: Failed to load class &quot;org.slf4j.impl.StaticLoggerBinder&quot;.
  SLF4J: Defaulting to no-operation (NOP) logger implementation
  SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
  Caught: java.lang.RuntimeException: java.lang.RuntimeException: java.util.concurrent.TimeoutException: Timed out while waiting for an available host - check the client configuration and connectivity to the server if this message persists
  Disconnected from the target VM, address: '127.0.0.1:59992', transport: 'socket'
  java.lang.RuntimeException: java.lang.RuntimeException: 
  java.util.concurrent.TimeoutException: Timed out while waiting for an available host - check the client configuration and connectivity to the server if this message persists
      at org.apache.tinkerpop.gremlin.driver.Client.submit(Client.java:214)
      at org.apache.tinkerpop.gremlin.driver.Client.submit(Client.java:198)
      at org.apache.tinkerpop.gremlin.driver.Client$submit.call(Unknown Source)
      at playpen.TinkerPop-Example.run(TinkerPop-Example.groovy:64)
  Caused by: java.lang.RuntimeException: java.util.concurrent.TimeoutException: Timed out while waiting for an available host - check the client configuration and connectivity to the server if this message persists
      at org.apache.tinkerpop.gremlin.driver.Client.submitAsync(Client.java:310)
      at org.apache.tinkerpop.gremlin.driver.Client.submitAsync(Client.java:242)
      at org.apache.tinkerpop.gremlin.driver.Client.submit(Client.java:212)
  </code></pre>
  <p>I have a couple of thoughts. I have a &quot;familyDB&quot; up from previous document DB prototype, but I can't figure what gremlin configure method in builder in user to express this.</p>
  <p>Further if you wanted to create dbs name from scratch and equiv of creating a collection for the graph vertices etc.</p>
  <p>Has anyone got a working graph config for the local cosmossDB emulator, and what have I done wrong/missed to cause this timeout. Attached is shot of debugger before I start issuing client commands</p>
  <p><a href="https://i.stack.imgur.com/DpEJf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DpEJf.png" alt="image from the debugger before client.submit " /></a></p>
  <p>PS - tried configuring cluster as per sample in Azure graph zip from GitHub.</p>
  <p>My config file looks like this</p>
  <p><code>hosts: [localhost] port: 8081 username: /dbs/familyDB/colls/FamilyCollection password: C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw== connectionPool: { enableSsl: true} serializer: { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0, config: { serializeResultToString: true }}</code></p>
  <p>And the modified code to get a connection now reads</p>
  <pre><code>try {
      File config = new File(&quot;D:/Intellij - Azure/quickstart-java/graph/src/main/cosmossDB-config.yaml&quot;)
      assert config.exists()
  
      Cluster.Builder builder = Cluster.build(config)
  
       cluster = builder.create()
      println cluster.dump()
  } catch (FileNotFoundException e) {
      e.printStackTrace()
      return
  }
  </code></pre>
  <p>and I have dumped the runtime values from the cluster instance which returns the following</p>
  <p><code>prop: maxWaitForConnection, with value 3000 prop: nioPoolSize, with value 8 prop: keepAliveInterval, with value 1800000 prop: loadBalancingStrategy, with value class org.apache.tinkerpop.gremlin.driver.LoadBalancingStrategy$RoundRobin prop: resultIterationBatchSize, with value 64 prop: port, with value 8081 prop: serializers, with value [application/json] prop: maxInProcessPerConnection, with value 4 prop: maxWaitForSessionClose, with value 3000 prop: reconnectInterval, with value 1000 prop: workerPoolSize, with value 16 prop: minInProcessPerConnection, with value 1 prop: class, with value class org.apache.tinkerpop.gremlin.driver.Cluster prop: sslEnabled, with value true prop: maxContentLength, with value 65536 prop: serializer, with value org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0@119020fb prop: factory, with value org.apache.tinkerpop.gremlin.driver.Cluster$Factory@3d9f6567 prop: closing, with value false prop: channelizer, with value org.apache.tinkerpop.gremlin.driver.Channelizer$WebSocketChannelizer prop: closed, with value false </code></p>
  <p>however the TimeoutExcption still occurs.</p>
  <p>I have downloaded the gremlin console and tried to <code>:remote connect</code> but when I run commands I get this, which warns about not responding in timely fashion.</p>
  <pre><code>`gremlin&gt; :remote connect tinkerpop.server conf/remote-cosmossDB.yaml
  log4j:WARN No appenders could be found for logger (io.netty.util.internal.logging.InternalLoggerFactory).
  log4j:WARN Please initialize the log4j system properly.
  log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
  ==&gt;Configured localhost/127.0.0.1:8081
  gremlin&gt;
  gremlin&gt; g.V()
  No such property: g for class: groovysh_evaluate
  Type ':help' or ':h' for help.
  Display stack trace? [yN]
  gremlin&gt; :remote list
  ==&gt;*0 - Gremlin Server - [localhost/127.0.0.1:8081]
  gremlin&gt; :remote console
  ==&gt;All scripts will now be sent to Gremlin Server - [localhost/127.0.0.1:8081] - type ':remote console' to return to local mode
  gremlin&gt; g.V()
  Host did not respond in a timely fashion - check the server status and submit again.
  Type ':help' or ':h' for help.
  Display stack trace? [yN]
  gremlin&gt; y
  Host did not respond in a timely fashion - check the server status and submit again.
  Type ':help' or ':h' for help.
  `
  </code></pre>
  <p>I am still stuck and can't get this to work - what can I try next?</p>