用令牌做认证
nats-server --auth mytokenConnecting with a Token
// Set a token
nc, err := nats.Connect("127.0.0.1", nats.Name("API Token Example"), nats.Token("mytoken"))
if err != nil {
log.Fatal(err)
}
defer nc.Close()
// Do something with the connectionOptions options = new Options.Builder().
server("nats://localhost:4222").
token("mytoken"). // Set a token
build();
Connection nc = Nats.connect(options);
// Do something with the connection
nc.close();const nc = await connect({
port: ns.port,
token: "aToK3n",
});Connecting with a Token in the URL
最后更新于