/// <summary> /// Connect to Nats server /// </summary> /// <param name="connstring">Nats Connection string</param> public void Connect(string connstring) { // Parse connection string var connparams = NatsUrlParser.Parse(connstring); MyNatsClient.Host host = new MyNatsClient.Host(connparams.host, connparams.port); // If the connection string has username and password, then use // that to authenticate Nats server if (connparams.HasCredentials()) { host.Credentials = new MyNatsClient.Credentials(connparams.username, connparams.password); } // Create client MyNatsClient.ConnectionInfo _connectionInfo = new MyNatsClient.ConnectionInfo(host); _client = new MyNatsClient.NatsClient(_connectionInfo); Task conn = _client.ConnectAsync(); conn.Wait(); }