Compose Database-as-a-Service Help and Documentation

Everything you need to know about Compose, Hosted or Enterprise, is here in our help system. Whether you run one database for your businesses' sole application or six different databases to support an entire corporation, we've got the information you need.

Websockets and Gremlin

WebSockets

WebSockets are an efficient way of creating a long-lived two-way connection over TCP and TLS which is ideal for interactive sessions between client applications and the JanusGraph server. There are a number of libraries for JanusGraph which use WebSockets as their connection to the server; to work with JanusGraph on Compose, they must be able to do basic authentication and to use WSS, secure WebSockets over TLS. The WebSocket connection strings can be found on the deployment's overview.

WebSocket Connection Strings

WebSocket Connection Strings

Gremlin Console

The Gremlin Console is the essential tool for working with Tinkerpop enabled servers. Gremlin Console uses the WebSockets connectivity, but does not use the URI syntax for connecting; this is partly because it also needs to configure other elements to work with the connection. ITe show the Gremlin Console Remote Connection YAML, which contains all that information, can be found in the deployment overview.

Gremlin Console Remote Connection YAML

Gremlin Console Remote Connection YAML

Downloading and installing

The pre-requisite for running the Gremlin Console is that you have a recent Java installed. Ensure you have that and then download the Gremlin Console version 3.3.3.

Once you have downloaded it, unzip the file and change directory into the new folder. Then, quickly check it runs by executing bin/gremlin.sh:

$ unzip -q  ~/Downloads/apache-tinkerpop-gremlin-console-3.3.3-bin.zip
$ cd apache-tinkerpop-gremlin-console-3.3.3
$ bin/gremlin.sh

         \,,,/
         (o o)
-----oOOo-(3)-oOOo-----
plugin activated: tinkerpop.server
plugin activated: tinkerpop.utilities
plugin activated: tinkerpop.tinkergraph
gremlin> [CONTROL-D]                                                             $

Configuring and connecting

The configuration for the Gremlin Console is on the overview page as we previously mentioned. The raw text of that configuration should be saved in a file in the conf directory.

In this example, we'll save it in conf/compose.yaml. Make sure that the password is showing in the JanusGraph overview. Select the contents of the Gremlin Console Remote Connection YAML and Command/Control-C to copy the contents to the clipboard. Feel free to use any other way of copying the clipboard to a file that you are comfortable with. Here we'll just use the cat command.

$ cat > conf/compose.yaml
[COMMAND/CONTROL-V to paste]
hosts: [portal93-4.ianuspater.compose-3.composedb.com]
port: 18045
username: admin
password: X99X99X99X99
connectionPool: { enableSsl: true }
serializer: { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { serializeResultToString: true }}
[CONTROL-D]
$ 

Now we can run the Gremlin console and connect.

$ bin/gremlin.sh

         \,,,/
         (o o)
-----oOOo-(3)-oOOo-----
plugin activated: tinkerpop.server
plugin activated: tinkerpop.utilities
plugin activated: tinkerpop.tinkergraph
gremlin> :remote connect tinkerpop.server conf/compose.yaml session
WARN  org.apache.tinkerpop.gremlin.driver.Cluster  - SSL configured without a trustCertChainFile and thus trusts all certificates without verification (not suitable for production)
==>Configured portal93-4.ianuspater.compose-3.composedb.com/159.8.153.216:18045-[2378d0de-0a93-4330-b8d8-848667f5b117]
gremlin>

The relevant command is :remote connect tinkerpop.server conf/compose.yaml session. If you type :help :remote, you'll see the :remote command has a number of options. We are telling it to connect to something that is a tinkerpop.server using the configuration in conf/compose.yaml. We're also passing another argument session which will enable session support.

The Gremlin console does not forward everything to the remote server automatically though. To send a command to the server you need to prefix the command with :> which literally means send the following command to the remote server. You can redirect all console commands to the remote server with :remote console. This makes interacting with the remote server very simple:

$ bin/gremlin.sh                                                                   

         \,,,/
         (o o)
-----oOOo-(3)-oOOo-----
plugin activated: tinkerpop.server
plugin activated: tinkerpop.utilities
plugin activated: tinkerpop.tinkergraph
gremlin> 1+1
==>2
gremlin> :> 1+1
==>No remotes are configured.  Use :remote command.
gremlin> :remote connect tinkerpop.server conf/compose.yaml session
WARN  org.apache.tinkerpop.gremlin.driver.Cluster  - SSL configured without a trustCertChainFile and thus trusts all certificates without verification (not suitable for production)
==>Configured portal93-4.ianuspater.compose-3.composedb.com/159.8.153.216:18045-[016d7a68-cf70-450e-92eb-4e5e2a647b5b]
gremlin> :remote console
==>All scripts will now be sent to Gremlin Server - [portal93-4.ianuspater.compose-3.composedb.com/159.8.153.216:18045]-[016d7a68-cf70-450e-92eb-4e5e2a647b5b] - type ':remote console' to return to local mode
gremlin> 1+1
==>2
gremlin> 

In Creating and accessing graphs, we'll introduce you to how you can interact with JanusGraph to create and access your graphs.


Still Need Help?

If this article didn't solve things, summon a human and get some help!

Websockets and Gremlin


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.