Skip to main content

Configuring the NATS Server

JAMS generates the NATS server configuration during installation. Most installations never need to change it. When you do, this page explains where to put the change so it survives upgrades, and which commands regenerate the files.

The Two Configuration Files​

Both live in the NATS folder, by default C:\Program Files\MVPSI\JAMS\Scheduler\NATS.

FileOwnerOn regeneration
nats-server-defaults.confJAMSReplaced. Any edit here is lost.
nats-server.confYouKept. Put your changes here.

nats-server.conf is the file the service loads. As installed, it only pulls in the JAMS defaults:

nats-server.conf (as installed)
# Include default NATS settings. Overrides below take precedence.
include "nats-server-defaults.conf"

To change a setting, add it below the include line. NATS applies the last value it reads, so anything after the include wins over the JAMS default.

Edit nats-server.conf, never nats-server-defaults.conf

JAMS rewrites the defaults file during an upgrade, when you run Update NATS Configuration, and when a tenant is created. Edits there are lost. JAMS also reads nats-server.conf, and only that file, to learn which port to connect to. A port override placed in the defaults file moves the server while the JAMS services keep dialing the old port.

The JAMS Defaults​

This is nats-server-defaults.conf on a standard install once TLS is set up. Paths reflect your install location.

nats-server-defaults.conf
# Default settings for NATS maintained by JAMS. Settings can be overridden in nats-server.conf.
listen: 0.0.0.0:4222
max_payload: 4194304
log_file: "C:/Program Files/MVPSI/JAMS/Scheduler/NATS/nats-server.log"
logtime: true
http: 127.0.0.1:8222
log_size_limit: 10000000
debug: false
trace: false
jetstream {
store_dir: "C:/ProgramData/JAMS/NATS"
}
# Mutual TLS. Clients must present a certificate signed by the JAMS root CA.
tls {
cert_file: "C:/Program Files/MVPSI/JAMS/Scheduler/NATS/nats-server-cert.pem"
key_file: "C:/Program Files/MVPSI/JAMS/Scheduler/NATS/nats-server-key.pem"
ca_file: "C:/Program Files/MVPSI/JAMS/Scheduler/NATS/nats-ca.pem"
verify: true
timeout: 5
min_version: "1.2"
}
SettingMeaning
listenAddress and port for client connections. 0.0.0.0 means all interfaces.
max_payloadLargest single message, 4,194,304 bytes (4 MiB).
log_file, logtimeLog destination, with timestamps.
httpRead-only monitoring endpoint, loopback only.
log_size_limitRoll the log at 10,000,000 bytes.
debug, traceVerbose logging, off by default.
jetstream.store_dirWhere reliable messages are stored.
tlsMutual TLS. verify: true means a client must present a certificate that chains to ca_file.

The tls block appears only once the three .pem files exist. Until then JAMS writes listen: 127.0.0.1:4222, so an unauthenticated server accepts connections from this machine only. See NATS TLS Certificates.

The Configuration Commands​

Run these in JAMSRegister.exe as Administrator from the Scheduler folder. They default to the NATS folder alongside JAMSRegister. Use /DIRECTORY=<folder> to point at another installation. The certificate commands use /DIRECTORYNAME=<folder> for the same thing.

CommandWhat it does
List NATS ConfigurationReports the configuration in effect: the files, the listen address and port, whether a failover peer can reach this server, whether mutual TLS is on, the certificates the tls block points at, and whether the server certificate is also in the certificate store (Server Certificate In Store). Read-only.
Add NATS Configuration [/FORCE]Generates both files on a machine that has none, and starts the JAMS NATS service if it is installed and stopped. Refuses to overwrite an existing configuration.
Update NATS Configuration [/RESTART] [/FORCE]Regenerates the defaults file, keeping your nats-server.conf. Adds the tls block when the .pem files are present and locks the folder down. Without /RESTART a running service is not disturbed and the command tells you a restart is still needed. With /RESTART it restarts the JAMS NATS service and the JAMS services that depend on it.
Remove NATS ConfigurationDeletes both files, including your overrides. No service is touched. A running service keeps its loaded configuration but will not start again until you run Add or Update.

Update NATS Configuration /RESTART is the step that makes a new or re-issued certificate take effect. The certificate commands never do it for you. See NATS TLS Certificates.

The folder certificate must be in the certificate store

When the .pem files are present, Add and Update check that the certificate in nats-server-cert.pem is in the Local Machine Personal store before they write anything. If it is not, the command stops with an error naming the folder certificate's thumbprint and subject. The NATS server would present that certificate, but the JAMS services authenticate with the certificate in the store, so a configuration written from a mismatched folder cannot work.

Fix it one of two ways. If the store holds the certificate you want, rewrite the folder from it with Export NATS Certificate /DIRECTORYNAME, then run Update NATS Configuration /RESTART. Otherwise re-issue: Destroy NATS Certificate, Create NATS Certificate, then Update NATS Configuration /RESTART. /FORCE writes the configuration anyway and prints the mismatch as a warning. Use it only when you know why the two differ. No check is made when the .pem files are absent. See NATS TLS Certificates.

JAMSDBA CONFIGURENATS is the older way to generate the configuration. Setup uses it on install paths that do not create the JAMS database. It does the same job as Update NATS Configuration, and it does not create a certificate.

Choosing the Certificate​

The store can hold more than one JAMS NATS certificate, for example during a rotation or after importing one issued elsewhere. Only one is in use at a time. It is the one whose thumbprint is in nats-server-cert.pem in the NATS folder. The NATS server presents that certificate, and each JAMS service looks up the same thumbprint in the store to find the certificate it presents as a client.

To make a different store certificate the active one, run Update NATS Configuration with /THUMBPRINT or /SUBJECT. The command writes the selected certificate's PEM files (leaf, key and issuing CA) into the NATS folder, then regenerates the configuration. The store is the source of truth. The folder holds whichever certificate you selected.

UPDATE NATS CONFIGURATION
[/THUMBPRINT=<cert thumbprint> | /SUBJECT=<cert subject>]
[/DIRECTORY=<NATS directory>]
[/RESTART | /NORESTART]
[/FORCE]
[/LOG | /NOLOG | /LOG=<logfile>]

ADD NATS CONFIGURATION
[/DIRECTORY=<NATS directory>]
[/FORCE]
[/LOG | /NOLOG | /LOG=<logfile>]
QualifierWhat it does
/THUMBPRINT=<thumbprint>On Update, selects the JAMS NATS certificate in the Local Machine Personal store with this thumbprint.
/SUBJECT=<subject>On Update, selects the JAMS NATS certificate by subject. Use either /THUMBPRINT or /SUBJECT, not both.
NeitherKeeps the certificate already in the folder.
/DIRECTORY=<folder>Configures a NATS folder other than the one alongside JAMSRegister.
/RESTARTOn Update, restarts the JAMS NATS service and the JAMS services that depend on it so the new certificate takes effect. If those services are running, the command asks for confirmation first, because the restart interrupts jobs running on this machine. Without it (/NORESTART, the default) the files are written and the command reports that a restart is still needed.
/FORCEWrites the configuration even when the certificate in the folder is not in the certificate store. The mismatch is reported as a warning.

The selected certificate must be a JAMS NATS certificate in the Local Machine Personal store. If /THUMBPRINT or /SUBJECT matches nothing, the command stops before writing anything. The command writes nats-ca.pem from this machine's Default Root CA, so that CA must be configured here and must be the one that issued the selected certificate. Otherwise the command stops before writing the folder, because the NATS TLS handshake would fail. Find thumbprints with List NATS Certificate, which marks the certificate currently in the folder. List NATS Configuration reports the active certificate under Server Certificate.

Create NATS Certificate refuses to run while a certificate exists, because it cannot know whether you meant to replace the one in use. To replace it, run Destroy NATS Certificate, Create NATS Certificate, then Update NATS Configuration /RESTART. To keep the old certificate for rollback, see Rotating the Certificate.

The client port is not a qualifier. To change it, edit nats-server.conf as described under Changing the Client Port.

Changing the Client Port​

Add listen to nats-server.conf:

nats-server.conf
# Include default NATS settings. Overrides below take precedence.
include "nats-server-defaults.conf"

listen: 0.0.0.0:5222

Then restart the service, which restarts the JAMS services with it:

Restart-Service JAMSNATSServer -Force

Confirm the change with List NATS Configuration, or from the log:

Select-String -Path "C:\Program Files\MVPSI\JAMS\Scheduler\NATS\nats-server.log" -Pattern "Listening for client connections"
Write the override as listen: <host>:<port>, unquoted

NATS and JAMS accept several forms, but the JAMS SCOM management pack reads this file with a narrower parser. A bare port, a bare host, port: instead of listen:, or a quoted value makes it monitor the wrong endpoint or fail. Use the plain host:port form. See SCOM Integration with NATS.

Failover pairs must use the same port

Each node connects to its peer on the port it has configured itself. If you change the port on one node, make the identical change on the other.

Changing the Monitoring Port​

nats-server.conf
include "nats-server-defaults.conf"

http: 127.0.0.1:9222

Keep the address on 127.0.0.1. The endpoint has no authentication. See Monitoring the NATS Server.

Increasing Log Detail​

nats-server.conf
include "nats-server-defaults.conf"

debug: true
trace: true
warning

trace: true logs every message the server handles and rolls the log quickly. Turn it on only while reproducing a problem, and turn it off afterwards.

The 4 MiB Message Size Limit​

max_payload caps a single message at 4 MiB. A JAMS operation that would produce a larger message fails rather than being truncated. The realistic case is a Sequence or Workflow Job that persists a large amount of state. If you see a message-size failure in the Scheduler log, raise the limit on every node:

nats-server.conf
include "nats-server-defaults.conf"

max_payload: 8388608

Applying a Change​

Restart the NATS service. Use -Force so Windows stops and restarts the dependent JAMS services with it:

Restart-Service JAMSNATSServer -Force
Get-Service JAMSNATSServer, JAMSScheduler, JAMSServer, JAMSExecutor

If the service will not start after an edit, the reason is in nats-server.log. A syntax error is reported there and the service exits. Fix or remove the override and restart.

Messaging Settings in the JAMS Database​

Two settings live in JAMS Configuration Settings rather than in the NATS files. Neither normally needs changing.

SettingDefaultPurpose
MessageInboxRetentionDays90How long the Scheduler remembers that it processed a message, so a redelivered copy is skipped.
ReliableForwardMaxAgeDays90In a failover pair, the oldest a queued message may be and still be forwarded to the active node. Capped at MessageInboxRetentionDays.

Neither exists in a new installation. The defaults are built in. To change one, add it first:

JAMSDBA ADD CONFIGURATION MessageInboxRetentionDays 120

See NATS Streams and Subjects Reference for what these protect and why lowering them is risky.