title: JanusGraph Load an existing graph with Gremlin.Net and Docker-Compose
body: <p>I'm currently working with janusgraph and gremlin via a <a href="https://github.com/andreazanetti92/janusgraph" rel="nofollow noreferrer">docker-compose</a>:</p>
  <pre><code>version: &quot;3.9&quot;
  
  services:
    janusgraph:
      image: docker.io/janusgraph/janusgraph:latest
      container_name: jce-janusgraph
      environment:
        JANUS_PROPS_TEMPLATE: cql-es
        janusgraph.storage.hostname: jce-cassandra
        janusgraph.index.search.hostname: jce-elastic
      ports:
        - &quot;8182:8182&quot;
      networks:
        - jce-network
      volumes:
        - ./mydata:/opt/janusgraph/mydata
      healthcheck:
        test: [&quot;CMD&quot;, &quot;bin/gremlin.sh&quot;, &quot;-e&quot;, &quot;scripts/remote-connect.groovy&quot;]
        interval: 10s
        timeout: 30s
        retries: 3
  
    cassandra:
      image: cassandra:3
      container_name: jce-cassandra
      ports:
        - &quot;9042:9042&quot;
        - &quot;9160:9160&quot;
      networks:
        - jce-network
  
    elasticsearch:
      image: docker.elastic.co/elasticsearch/elasticsearch:6.6.0
      container_name: jce-elastic
      environment:
        - &quot;ES_JAVA_OPTS=-Xms512m -Xmx512m&quot;
        - &quot;http.host=0.0.0.0&quot;
        - &quot;network.host=0.0.0.0&quot;
        - &quot;transport.host=127.0.0.1&quot;
        - &quot;cluster.name=docker-cluster&quot;
        - &quot;xpack.security.enabled=false&quot;
        - &quot;discovery.zen.minimum_master_nodes=1&quot;
      ports:
        - &quot;9200:9200&quot;
      networks:
        - jce-network
  
  networks:
    jce-network:
  volumes:
    janusgraph-default-data:
  </code></pre>
  <p>Inside /mydata I have a graphml that I'd like to load in order to using it in my .net 6 web api. In gremlin console I'm able to load that graph.
  I searched online but I have not found anything on how to load a graph with Gremlin.Net.</p>
  <p>I was thinking to create a Seed class with a static method that load the graph and then call in Program</p>
  <h3><strong>Edit</strong></h3>
  <p>I create Seed.cs:</p>
  <pre><code>public static class Seed
      {
          public static void LoadGraph(GraphTraversalSource g)
          {
  
             //g.Io&lt;Graph&gt;(&quot;C:\\Users\\ext-azanetti\\Desktop\\janusgraph\\mydata\\air-routes.graphml&quot;);
             g.Io&lt;Graph&gt;(&quot;http://jce-janusgraph:8182/opt/janusgraph/mydata/air-routes.graphml&quot;);
  
          }
      }
  </code></pre>
  <p>Then i call seed in my Program.cs:</p>
  <pre><code>...
  builder.Services.AddSingleton&lt;GremlinClient&gt;((serviceProvider) =&gt;
  {
      var gremlinServer = new GremlinServer(
          hostname: &quot;localhost&quot;,
          port: 8182,
          enableSsl: false,
          username: null,
          password: null
          );
  
      var connectionPoolSettings = new ConnectionPoolSettings
      {
          MaxInProcessPerConnection = 32,
          PoolSize = 4,
          ReconnectionAttempts = 4,
          ReconnectionBaseDelay = TimeSpan.FromSeconds(1),
      };
  
      return new GremlinClient(
          gremlinServer: gremlinServer,
          messageSerializer: new GraphSON3MessageSerializer(new GraphSON3Reader(), new GraphSON3Writer()),
          connectionPoolSettings: connectionPoolSettings
          );
  });
  
  builder.Services.AddSingleton&lt;GraphTraversalSource&gt;((serviceProvider) =&gt;
  {
      GremlinClient gremlinClient = serviceProvider.GetService&lt;GremlinClient&gt;();
      var driverRemoteConnection = new DriverRemoteConnection(gremlinClient, &quot;g&quot;);
      return AnonymousTraversalSource.Traversal().WithRemote(driverRemoteConnection);
  });
  ...
  try
  {
      var g = app.Services.GetService&lt;GraphTraversalSource&gt;();
      if (g != null) Seed.LoadGraph(g);
      else throw new Exception(&quot;Cannot get service GraphTraversalSource to load data&quot;);
  }
  catch (Exception ex)
  {
      throw new Exception(&quot;Fail to load the graph&quot;, ex);
  }
  ...
  </code></pre>
  <p>It doesn't work. And it doesn't throw any execption.</p>
  <h3><strong>Update</strong></h3>
  <p>I delete the Seed.cs and in put all inside Program.cs:</p>
  <pre><code>builder.Services.AddSingleton&lt;GremlinClient&gt;((serviceProvider) =&gt;
  {
      var gremlinServer = new GremlinServer(
          hostname: &quot;localhost&quot;,
          port: 8182,
          enableSsl: false,
          username: null,
          password: null
          );
  
      var connectionPoolSettings = new ConnectionPoolSettings
      {
          MaxInProcessPerConnection = 32,
          PoolSize = 4,
          ReconnectionAttempts = 4,
          ReconnectionBaseDelay = TimeSpan.FromSeconds(1),
      };
  
      return new GremlinClient(
          gremlinServer: gremlinServer,
          messageSerializer: new GraphSON3MessageSerializer(new GraphSON3Reader(), new GraphSON3Writer()),
          connectionPoolSettings: connectionPoolSettings
          );
  });
  
  builder.Services.AddSingleton&lt;GraphTraversalSource&gt;((serviceProvider) =&gt;
  {
      GremlinClient gremlinClient = serviceProvider.GetService&lt;GremlinClient&gt;();
      var driverRemoteConnection = new DriverRemoteConnection(gremlinClient, &quot;g&quot;);
      var g = AnonymousTraversalSource
              .Traversal()
              .WithRemote(driverRemoteConnection);
      
      // ##### CODE ADDED IN UPDATE ######
      g.Io&lt;Graph&gt;(&quot;/opt/janusgraph/mydata/air-routes.graphml&quot;)
          .With(IO.reader, IO.graphml);
      return g;
  });
  </code></pre>
  <p>Now it's throw <em>InvalidRequestArguments: The traversal source [g] for alias [g] is not configured on the server</em>.
  Now I'm trying to figure out how to solve this exception.</p>