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 find | Cause | Fix |
|---|---|---|
No nats-server.conf or nats-server-defaults.conf in the NATS folder | The configuration was never generated | Run Add NATS Configuration in JAMSRegister. Then set up TLS. See NATS TLS Certificates. |
A bind error such as Only one usage of each socket address | Another process holds port 4222 or 8222, possibly a second hand-started jams-nats-server.exe | Find 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 line | A syntax error in an override in nats-server.conf | Fix or remove the override and restart. |
Can't start monitoring | Port 8222 is in use | Change the monitoring port with an http: override. |
| Nothing in the log and the service will not start | The service account cannot read the NATS folder or write C:\ProgramData\JAMS\NATS | Grant 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 see | Meaning | Fix |
|---|---|---|
nats stream ls shows no streams | The 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 0 | Messages are arriving and nothing is consuming them | Restart the JAMS Scheduler service. If it recurs, collect the Scheduler log and contact Support. |
| Outstanding Acks stuck at 1 | The Scheduler took a message and is stuck on it | Check 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 run | Messaging is healthy. The problem is elsewhere. | In a failover pair, confirm this node is active. Then look at the schedule and Job definitions. |
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.
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.
| Finding | Cause | Fix |
|---|---|---|
| The passive node's Scheduler is stopped | Nothing is forwarding reliable messages. They queue locally. | Start the Scheduler on both nodes. |
Listen address is 127.0.0.1 | No certificates on this node, so NATS refuses network connections | Issue the certificate. See NATS in a Failover Environment. |
| 4222 reachable but 4773 is not | The passive node cannot learn which node holds control, so it never forwards | Allow inbound TCP 4773, or your Failover.config port, on both nodes. |
Test-NetConnection fails on 4222 | Firewall | Allow inbound TCP 4222 on both nodes. |
| Neither node holds control | Forwarding pauses by design. Messages wait locally. | Confirm one node is active with Get-JAMSFailoverStatus. Expected during a switchover. |
TLS error from nats server check connection | The nodes' certificates chain to different root CAs | Import 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.
- Look in the Scheduler log for
The MSMQ drain did not complete and will be retried on the next start. - Fix what it reports. Usually NATS was not reachable when the Scheduler started.
- Restart the JAMS Scheduler service.
See Upgrading from MSMQ to NATS.
Certificate and TLS Errors
| Message | Meaning | Fix |
|---|---|---|
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 Create | Create NATS Certificate, then Update NATS Configuration /RESTART |
NATS Certificate already exists in Certificate Store | Create without Destroy first | Destroy 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 present | The store holds more than one JAMS NATS certificate, so the command cannot pick one | Destroy NATS Certificate /THUMBPRINT=<thumbprint>. Find thumbprints with List NATS Certificate. |
Multiple JAMS NATS certificates found in the store from Export | Same cause | Export NATS Certificate /THUMBPRINT=<thumbprint> ... or /SUBJECT=<subject> |
Not a JAMS NATS Certificate from Import | The .pfx holds a certificate whose subject does not begin with JAMS NATS-, or that is not valid for both TLS server and client use | Issue 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 /DIRECTORYNAME | nats-ca.pem is written from the machine's default root CA, and that is not the CA that issued this certificate | Import 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 store | The .pem files are stale, were copied from another machine, or a certificate was created into a different folder | If 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 missing | JAMS is installed somewhere other than the folder alongside JAMSRegister, or the folder was removed | Point 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.log | A client connected without a certificate | Usually 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.log | The shared root CA is not in this machine's store | Import 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.log | Issuing 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.
The configuration files contain paths but no secrets. Never send nats-server-key.pem. It is the server's private key.