Skip to content

Instantly share code, notes, and snippets.

@ColinSullivan1
Created July 10, 2020 20:43
Show Gist options
  • Save ColinSullivan1/e91696ba4d23f4091cc54ee36ce833f7 to your computer and use it in GitHub Desktop.
Save ColinSullivan1/e91696ba4d23f4091cc54ee36ce833f7 to your computer and use it in GitHub Desktop.
NGS Connect Java Code

Connecting to NGS with the Java NATS client version 2.6.8

In order to connect to NGS with the NATS java client, you need to include a java dependency for ED25519 support, set the connection to secure, and enable the NATS credentials.

        Options o = new Options.Builder().
	         authHandler(server("nats://connect.ngs.global:4222").
                 Nats.credentials("/users/colinsullivan/.nkeys/creds/synadia/First/First.creds"))
                 secure().
                 maxReconnects(-1).  // optionally reconnect forever
                 build();
 
        Connection nc = Nats.connect(o);

Dependencies

You'll need to include the ED25519 support. Add this jar into your project/classpath: https://mvnrepository.com/artifact/net.i2p.crypto/eddsa/0.3.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment