Skip to content

Server support

Cratis Chronicle connection strings specify server addresses, authentication and connection options. This reference describes the .NET client’s behavior.

Connection strings follow this general format:

chronicle://[username:password@]host[:port][,host[:port],...][/?options]
chronicle+srv://[username:password@]host[/?options]
  • Scheme: chronicle:// for explicit hosts, or chronicle+srv:// for DNS SRV record lookup
  • Authentication (optional): username:password@ for client credentials authentication
  • Host: The server hostname or IP address. Multiple hosts can be given as a comma-separated list, each with an optional port
  • Port (optional): Defaults to 35000
  • Options (optional): Query string parameters for additional configuration

When the connection string holds more than one host, the client picks which server to connect to using a load balancer strategy. The strategy is applied on every connect - including reconnects, so a client fails over to the next server when the one it is connected to becomes unavailable.

chronicle://node1:35000,node2:35000,node3:35000
Strategy Description
least-connections Default. With multiple candidates, asks each server for its connection count, including pending reservations, and picks the lowest count. See below for how the probe works
round-robin Cycles through the servers in order, starting at a random offset. Independently started clients can still pick the same server; least-connections uses server counts to reduce this risk, but does not guarantee an even spread
random Picks a random server on every connect

Select the strategy with the loadBalancer query parameter, or programmatically through ChronicleOptions.LoadBalancerStrategy for custom implementations of ILoadBalancerStrategy:

chronicle://node1:35000,node2:35000?loadBalancer=round-robin

Every Chronicle Server exposes two anonymous endpoints for this - anonymous because a client needs to ask before it has authenticated:

Endpoint Purpose
GET /connections/count Returns the connected-client count plus unexpired reservations for that specific server - not the cluster-wide total
POST /connections/reserve Reserves a connection slot on that server ahead of the client actually connecting

When more than one candidate remains, the client asks each candidate server for its count in parallel and picks the lowest count - ties are broken randomly rather than always preferring the first candidate. It then makes a best-effort call to POST /connections/reserve on the server it picked before starting the connection handshake. A failed reservation does not stop the connection attempt. With a single candidate, the client connects without probing or reserving a slot.

A successful reservation makes a pending connection visible in /connections/count before the client has finished connecting. Later probes can account for that pending connection instead of all seeing the same low count. When a real connection registers, the server removes its oldest outstanding reservation. Reservations not consumed by a connection expire; their lifetime defaults to 30 seconds and is configurable on the server.

Before every multi-candidate probe, including on reconnect, the client waits a random delay below 250ms by default. This reduces synchronized probes from clients starting or reconnecting together. The delay and reservations reduce collisions, but cannot prevent concurrent clients from picking the same server.

A server that doesn’t answer within 2 seconds, or that can’t be reached at all, is treated as maximally loaded rather than failing the selection - it simply won’t be picked over a server that did respond. This makes least-connections a safe default even while a server is restarting or briefly unreachable: the client prefers a server that answered. If every probe fails, all candidates tie at the maximum count and one is selected randomly; selection does not establish that it is reachable.

With the chronicle+srv:// scheme, the client resolves the servers from DNS SRV records instead of listing them explicitly - the same mechanism MongoDB uses for mongodb+srv://. The client looks up _chronicle._tcp.<host> and uses the returned targets and ports as the server list, ordered by SRV priority and weight. The lookup happens on every connect, so servers added to or removed from DNS are picked up on reconnect without configuration changes.

chronicle+srv://cluster.example.com

For the example above, the client queries the SRV records for _chronicle._tcp.cluster.example.com.

With client credentials and no external token endpoint, the client requests its token from the server it connects to: https://<target>:<port>/connect/token. With SRV discovery, <target> is the host the SRV record returned, so the client id and secret are sent to whichever host DNS names. Whoever controls the SRV records for the domain therefore controls where the credentials go. Only use chronicle+srv:// with a domain whose DNS you trust, ideally DNSSEC-protected, or configure an explicit external token endpoint so credentials always go to a fixed destination. Credentials are only sent over TLS.

Short-lived clients, such as command line tools, can cache tokens between runs with FileSystemCachingTokenProvider, which stores them in a file at a path the host application chooses (keep it in the user’s own profile). The cache path must be unique per server and client identity. Prefer the four-parameter overload (innerProvider, cacheFilePath, tokenLifetime, cacheScope), supplying a scope that combines the server address and client id. Only the scope’s SHA-256 hash is stored; entries with a missing or different hash are ignored and replaced. The original overload does not check a scope, so the caller remains responsible for keeping its cache path unique.

The file is created readable and writable by the current user only (mode 0600 on Unix, in a directory with mode 0700) and replaced atomically. Existing Unix directories owned by the current user are also restricted to 0700; cache files owned by another user or accessible to group or others are not trusted. On Windows the directory and temporary file are created with protected access control lists granting FullControl only to the current user. The replacement retains the temporary file’s protection.

A cached token is reused for at most the configured lifetime (55 minutes by default). A JWT’s issuer expiry (exp) less a 30-second safety margin can shorten that lifetime, but never extend it. Delete the file to force a new token request.

Chronicle supports multiple authentication modes. The mode is determined by the credentials present in the connection string:

  • Client credentials: Username and password supplied in the authority section. With TLS enabled, no credentials and no external token endpoint or authority configured, the client falls back to the development credentials. An external token endpoint or authority requires explicit client credentials. With disableTls=true and no credentials, the client instead connects without authentication
  • API key: apiKey query parameter
  • None: auth=none query parameter — the client presents no credentials at all

You cannot combine client credentials and API key authentication in the same connection string. auth=none overrides both, so credentials left behind by a shared configuration cannot quietly turn the exchange back on.

auth=none only works against a server running with authentication turned off, which is meant for a Chronicle embedded alongside its own client rather than reachable over a network. Against a server that enforces authentication, calls to protected services fail as unauthenticated.

Parameter Type Description Example
auth string Set to none to connect without presenting credentials ?auth=none
apiKey string API key for API key authentication ?apiKey=your-api-key
skipTlsValidation boolean Set false to require server certificate validation; true is a development-only opt-out ?skipTlsValidation=false
disableTls boolean Connects without TLS, over cleartext HTTP/2 (h2c), to a server running with tls.enabled=false. See Connecting without TLS ?disableTls=true
skipCompatibilityCheck boolean Skips the connect-time wire-compatibility check against the server ?skipCompatibilityCheck=true
serverless boolean Turns on serverless mode in the .NET client (equal to Cratis:Chronicle:Serverless:Mode=Serverless). Implies skipping keep-alive. Other clients ignore it ?serverless=true
skipKeepAlive boolean Skips the keep-alive connection, for short-lived processes. A client that skips it cannot host reactors or reducers ?skipKeepAlive=true
loadBalancer string Load balancer strategy when multiple servers are configured ?loadBalancer=round-robin
srvNameServer string DNS name server (host[:port], port defaults to 53) for chronicle+srv lookups; defaults to the system’s name servers ?srvNameServer=10.0.0.53

The .NET client connects over TLS unless disableTls=true is set. When both validation settings are omitted, it still skips server certificate validation in this release. We recommend explicitly setting skipTlsValidation=false after configuring certificate trust or a matching pin. Either an explicit skipTlsValidation=false or Tls.SkipCertificateValidation=false requires validation, even if the other option is true and even on localhost. Otherwise an explicit true skips validation. With TLS disabled, certificate validation does not apply.

For development only, use chronicle://localhost:35000?skipTlsValidation=true to explicitly opt out. The development images (latest-development and latest-development-slim) generate an untrusted, self-signed certificate on every start when none is configured, with SANs localhost, chronicle, 127.0.0.1, and ::1. The production image (latest and version tags) does not generate a certificate and requires one when TLS is enabled; see Production deployment.

The next major release will enable validation by default. Connection-string builders preserve omitted settings and explicit true or false through serialization and credential helpers. A startup warning is logged when validation is skipped for a remote host or an SRV lookup, not on loopback targets; it is suppressed when TLS is disabled.

See TLS configuration (client) for certificate setup.

A server running with tls.enabled=false serves cleartext HTTP/2 (h2c) only, for example behind a TLS-terminating proxy that forwards h2c. Set disableTls=true when connecting directly to that cleartext listener, including through kubectl port-forward, for example chronicle://localhost:35001/?disableTls=true&auth=none. Port forwarding does not itself disable TLS; a server with TLS enabled still requires a TLS connection.

Chronicle serves its token endpoint (/connect/token) over TLS only. With TLS disabled and authentication turned on, the server requires an external HTTPS authority. So a client connecting with disableTls=true cannot exchange client credentials:

  • With no credentials, the client connects without authentication, as with auth=none. It does not fall back to the development credentials.
  • With explicit client credentials, creating the connection fails with ClientCredentialsRequireTls, which names the alternatives.
  • With apiKey=<token>, the client presents a token you obtained from the server’s external authority.

Before treating a connection as usable, the client checks that its wire contract and the server’s are still compatible — see Clustering and the connection lifecycle: the wire-compatibility handshake for how the check itself works. This is a real safety check, not a formality: it exists to catch a genuine mismatch, such as a client sent to a server that no longer has fields or methods the client depends on.

Set skipCompatibilityCheck=true only as a deliberate, temporary escape hatch — for example when a client that has only gained capabilities since the server’s release is (incorrectly) refused by a server that cannot be redeployed immediately. Skipping the check does not make an incompatibility disappear; it trades a clear, immediate connect-time failure for whatever less obvious failure the actual incompatibility causes later. Remove the setting once the server is upgraded or the client’s assumption about compatibility is otherwise confirmed.