Skip to main content

Troubleshooting NATS

Work through this page from the top. The JAMS services depend on the NATS service, so a NATS problem shows up as a JAMS problem.

Start Here​

# 1. Is the NATS service running, and did the JAMS services start?
Get-Service JAMSNATSServer, JAMSScheduler, JAMSServer, JAMSExecutor

# 2. Is the broker healthy?
Invoke-RestMethod http://127.0.0.1:8222/healthz

# 3. Is TLS on, and is anything backing up?
Invoke-RestMethod http://127.0.0.1:8222/varz | Select-Object tls_required, tls_verify, connections
Invoke-RestMethod "http://127.0.0.1:8222/jsz?streams=1" |
Select-Object -ExpandProperty account_details |
Select-Object -ExpandProperty stream_detail |
Select-Object name, @{n='Messages';e={$_.state.messages}}

# 4. What does the NATS log say?
Get-Content "C:\Program Files\MVPSI\JAMS\Scheduler\NATS\nats-server.log" -Tail 40

In JAMSRegister, run as Administrator from the Scheduler folder, List NATS Configuration reports the configuration in effect and List NATS Certificate reports the certificate in the store alongside the certificate files in the NATS folder, with In Certificate Store: Yes or No for the folder certificate. DBUpdate.log in the Scheduler folder records everything setup did to NATS.

All the JAMS Services Fail to Start​

The JAMS Scheduler, Server, and Executor each depend on JAMSNATSServer. If the NATS service cannot start, Windows refuses to start any of them.

Start-Service JAMSNATSServer
Get-Content "C:\Program Files\MVPSI\JAMS\Scheduler\NATS\nats-server.log" -Tail 40
What you findCauseFix
No nats-server.conf or nats-server-defaults.conf in the NATS folderThe configuration was never generatedRun Add NATS Configuration in JAMSRegister. Then set up TLS. See NATS TLS Certificates.
A bind error such as Only one usage of each socket addressAnother process holds port 4222 or 8222, possibly a second hand-started jams-nats-server.exeFind the owner with Get-NetTCPConnection -LocalPort 4222. Stop it, or change the JAMS port. See Configuring the NATS Server.
A configuration parse error naming a lineA syntax error in an override in nats-server.confFix or remove the override and restart.
Can't start monitoringPort 8222 is in useChange the monitoring port with an http: override.
Nothing in the log and the service will not startThe service account cannot read the NATS folder or write C:\ProgramData\JAMS\NATSGrant it access. Setup restricts both folders.

The Scheduler Is Running but Nothing Is Being Processed​

Jobs do not start and completions do not register, but no service is down.

cd "C:\Program Files\MVPSI\JAMS\Scheduler\NATS"
nats stream info JAMS_RELIABLE
nats consumer info JAMS_RELIABLE JAMS_SCHEDULER
What you seeMeaningFix
nats stream ls shows no streamsThe Scheduler never connected. Streams are created only by the running services.Look in the Scheduler log for a connection or TLS error, then restart the Scheduler.
Messages and Unprocessed Messages rising, Outstanding Acks at 0Messages are arriving and nothing is consuming themRestart the JAMS Scheduler service. If it recurs, collect the Scheduler log and contact Support.
Outstanding Acks stuck at 1The Scheduler took a message and is stuck on itCheck the Scheduler log for what it is working on. This is usually a database or Job issue.
Stream near 0 messages, but Jobs still do not runMessaging is healthy. The problem is elsewhere.In a failover pair, confirm this node is active. Then look at the schedule and Job definitions.
In a failover pair, check which node is active

A passive node forwards work rather than processing it. A passive node with a near-empty stream is behaving correctly.

Get-JAMSFailoverStatus -Server <NodeName>

The Message Store Is Growing​

C:\ProgramData\JAMS\NATS grows when reliable messages arrive faster than they are processed, or are not processed at all. This is a consumption problem, not a capacity problem. Work through the previous section rather than raising the limit. The stream is capped at 1 GiB and then rejects new messages, which surfaces as send failures in the JAMS logs.

warning

Do not purge the stream to reclaim space. Those messages are unprocessed scheduling work. See Using the NATS Admin CLI.

A Job Appears to Hang​

If a Sequence or Workflow Job stops making progress, check whether it tried to send a message larger than 4 MiB. Look in the Scheduler and Executor logs for a payload or size error, and for Exception while writing a reliable NATS message. Raise max_payload on every node. See Configuring the NATS Server.

If NATS itself was unreachable when a service needed to send a reliable message, the message is written to a local spool under C:\ProgramData\JAMS\NATS\spool and published when NATS returns. A spool that keeps growing means NATS has been down for some time.

Cross-Node Messaging Is Not Working (Failover)​

Work committed on the passive node never reaches the active Scheduler.

# 1. Is the passive node's Scheduler service running? It forwards reliable messages.
Get-Service JAMSScheduler

# 2. Are both inter-node ports open? 4773 gates forwarding, 4222 carries it.
Test-NetConnection <OtherNodeName> -Port 4222
Test-NetConnection <OtherNodeName> -Port 4773

# 3. Can this node connect to the peer over mutual TLS?
cd "C:\Program Files\MVPSI\JAMS\Scheduler\NATS"
nats context add peer --server nats://<OtherNodeName>:4222 `
--tlsca nats-ca.pem --tlscert nats-server-cert.pem --tlskey nats-server-key.pem --select
nats server check connection

And in JAMSRegister on each node, List NATS Configuration. Reachable From Other Machines must be yes and Mutual TLS on.

FindingCauseFix
The passive node's Scheduler is stoppedNothing is forwarding reliable messages. They queue locally.Start the Scheduler on both nodes.
Listen address is 127.0.0.1No certificates on this node, so NATS refuses network connectionsIssue the certificate. See NATS in a Failover Environment.
4222 reachable but 4773 is notThe passive node cannot learn which node holds control, so it never forwardsAllow inbound TCP 4773, or your Failover.config port, on both nodes.
Test-NetConnection fails on 4222FirewallAllow inbound TCP 4222 on both nodes.
Neither node holds controlForwarding pauses by design. Messages wait locally.Confirm one node is active with Get-JAMSFailoverStatus. Expected during a switchover.
TLS error from nats server check connectionThe nodes' certificates chain to different root CAsImport the shared root with /STOREKEY /MakeDefault, then Destroy NATS Certificate, Create NATS Certificate, Update NATS Configuration /RESTART.

SCOM Alerts Are Not Arriving​

See SCOM Integration with NATS. The two most common causes are an out-of-date management pack and a SCOM RunAs account that cannot read the certificate files.

The MSMQ Queues Were Not Removed after Upgrading​

Get-MsmqQueue -Name "JAMSRequests","JAMStoSCOM" -ErrorAction SilentlyContinue

If a queue is still present, the drain did not finish. It is retried every time the Scheduler starts.

  1. Look in the Scheduler log for The MSMQ drain did not complete and will be retried on the next start.
  2. Fix what it reports. Usually NATS was not reachable when the Scheduler started.
  3. Restart the JAMS Scheduler service.

See Upgrading from MSMQ to NATS.

Certificate and TLS Errors​

MessageMeaningFix
NATS is configured for TLS but no usable JAMS NATS client certificate was found in the Local Machine personal store.The .pem files and tls block are present but the certificate is gone from the store, usually Destroy without a following CreateCreate NATS Certificate, then Update NATS Configuration /RESTART
NATS Certificate already exists in Certificate StoreCreate without Destroy firstDestroy NATS Certificate, then Create. To add a second certificate alongside the first instead, use Import NATS Certificate.
Unique JAMS NATS Certificate not found. from Destroy while a certificate is presentThe store holds more than one JAMS NATS certificate, so the command cannot pick oneDestroy NATS Certificate /THUMBPRINT=<thumbprint>. Find thumbprints with List NATS Certificate.
Multiple JAMS NATS certificates found in the store from ExportSame causeExport NATS Certificate /THUMBPRINT=<thumbprint> ... or /SUBJECT=<subject>
Not a JAMS NATS Certificate from ImportThe .pfx holds a certificate whose subject does not begin with JAMS NATS-, or that is not valid for both TLS server and client useIssue it with Create NATS Certificate, which applies those requirements. See NATS TLS Certificates.
The certificate was issued by ... but the configured Default Root CA is ... from Export or Import with /DIRECTORYNAMEnats-ca.pem is written from the machine's default root CA, and that is not the CA that issued this certificateImport and make default the root CA that issued the certificate, then rerun the command
List NATS Certificate shows In Certificate Store: No for the folder certificate, or Update NATS Configuration stops with an error that the folder certificate is not in the storeThe .pem files are stale, were copied from another machine, or a certificate was created into a different folderIf the store holds the certificate you want: Export NATS Certificate /DIRECTORYNAME, then Update NATS Configuration /RESTART. Otherwise re-issue: Destroy, Create, Update NATS Configuration /RESTART. /FORCE on the configuration command writes the file anyway, but the JAMS services cannot connect until the two agree.
List NATS Certificate reports the NATS folder as missingJAMS is installed somewhere other than the folder alongside JAMSRegister, or the folder was removedPoint the command at the right folder with /DIRECTORYNAME=<folder>. If the folder is gone, run Create NATS Certificate to recreate it.
remote error: tls: certificate required in nats-server.logA client connected without a certificateUsually a SCOM RunAs account that cannot read the .pem files. See SCOM Integration with NATS.
The Root CA is not available. TLS will have to be set up manually. in DBUpdate.logThe shared root CA is not in this machine's storeImport it with /STOREKEY /MakeDefault, then issue the certificate. See NATS in a Failover Environment.
Unable to create the NATS TLS certificate. NATS will run without TLS in DBUpdate.logIssuing failed. NATS is running on loopback only.Read the reason on that line, fix it, then Create NATS Certificate and Update NATS Configuration /RESTART.

More detail: NATS TLS Certificates.

Collecting Information for Support​

cd "C:\Program Files\MVPSI\JAMS\Scheduler\NATS"
$dest = "$env:TEMP\jams-nats-diag"
New-Item -ItemType Directory -Force -Path $dest | Out-Null

Get-Service JAMSNATSServer, JAMSScheduler, JAMSServer, JAMSExecutor | Out-File "$dest\services.txt"
Copy-Item "nats-server.log", "nats-server.conf", "nats-server-defaults.conf" $dest -ErrorAction SilentlyContinue
Copy-Item "..\DBUpdate.log" $dest -ErrorAction SilentlyContinue
Invoke-RestMethod http://127.0.0.1:8222/varz | ConvertTo-Json -Depth 4 | Out-File "$dest\varz.json"
Invoke-RestMethod "http://127.0.0.1:8222/jsz?streams=1&consumers=1" | ConvertTo-Json -Depth 6 | Out-File "$dest\jsz.json"
nats stream report | Out-File "$dest\streams.txt"
nats consumer info JAMS_RELIABLE JAMS_SCHEDULER | Out-File "$dest\consumer.txt"

Compress-Archive "$dest\*" "$env:TEMP\jams-nats-diag.zip" -Force
"$env:TEMP\jams-nats-diag.zip"

Add the output of List NATS Configuration and the JAMS Scheduler log, and say which node of a failover pair the data came from.

note

The configuration files contain paths but no secrets. Never send nats-server-key.pem. It is the server's private key.