Docs menu

Troubleshooting

Start with the pitfalls below. Most integration problems are one of them. If yours isn't, use the debugging toolkit to find which stage fails, then look up the symptom.

Common pitfalls

  • A token alone doesn't grant a room. The user also needs a member row in user_roles and a row in room_members. Grant both through the host SDK (setUserRole and addRoomMembers). See Rooms and membership.
  • Tokens longer than 60 minutes are rejected. exp - iat must be at most Auth:MaxTokenLifetimeMinutes. A token without iat, or with iat more than 30 seconds in the future, is also rejected, so check the clock on the machine that mints tokens.
  • The kid must match exactly. The token header's kid selects the key. With Auth__Keys__dev, the host must sign with keyId: 'dev'.
  • The private key goes in the host, the public key in dotwire. Putting a private key in Auth:Keys fails startup, by design.
  • Room ids are UUIDs. Anything else returns 404 on member routes and 400 on admin routes. The Node host SDK throws a TypeError before sending.
  • Each node role serves different routes. Gateway nodes serve only the hub and SSE, and Api nodes serve everything else. A request that lands on the wrong role gets 404. See Node roles.
  • The browser client needs CORS, and has to use the WebSockets transport. Add your app's origin to Cors__AllowedOrigins__0. dotwire never allows credentialed cross-origin requests, so transport: 'negotiate' fails from another origin. Keep the default 'websockets'.
  • Webhook handlers need all three signature headers. Pass X-Dotwire-Signature, X-Dotwire-Timestamp and X-Dotwire-Signature-V2, and verify against the raw body. Re-serialized JSON won't match. See Moderation webhooks.
  • Rate limits and connection caps are per node. With several nodes behind a load balancer, the effective limit is the configured value times the number of nodes. Behind a proxy, every unauthenticated client shares the proxy's IP in the Unauthenticated bucket.
  • An ack isn't the same as being in history. A 202 means JetStream stored the message. Postgres catches up in batches, about a second later, and history reads fill the gap from JetStream.
  • Participants aren't presence. getParticipants() returns room members. Presence events describe who is connected right now, and there's no presence snapshot.
  • In React, a failed send only rejects its promise. useRoom().send() leaves status and error unchanged, so a send with no catch fails silently in your UI. See useRoom.
  • Never remove an old encryption key. Messages encrypted under it become unreadable. Add a new key id and switch ActiveKeyId instead. See Encryption and retention.

Debugging toolkit

Check that dotwire is up

curl -i http://localhost:8080/healthz

200 means the node is serving. In a container, /app/dotwire --healthcheck runs the same check and exits 0 on success.

Read the token

Decode the token's payload and check iss, aud, sub, dw:role, iat and exp:

node -e 'const [h,p]=process.argv[1].split(".");for (const s of [h,p]) console.log(JSON.parse(Buffer.from(s,"base64url")))' "$TOKEN"

The first object is the header: check alg is RS256 and kid matches a configured key. In the second, exp - iat must be 3,600 seconds or less.

Test every auth stage with one request

The participants endpoint runs the whole pipeline: signature, standard claims, role cross-check, and room membership.

curl -i -H "Authorization: Bearer $TOKEN" "$DOTWIRE/rooms/$ROOM_ID/participants"
ResponseWhat failed
200 with a list of user idsNothing. Token, role and membership are all fine.
401The token itself: signature, kid, iss, aud, expiry, or lifetime.
403The token is valid, but the role doesn't match user_roles, or the user isn't in the room.
404The room id isn't a UUID, or the request reached a Gateway node.

See why a token was rejected

401 responses have no body. The WWW-Authenticate header usually names the failed check, for example an expired token or a wrong audience. To see every rejection, including dotwire's own checks on iat and lifetime, raise the authentication log level:

Logging__LogLevel__Microsoft.AspNetCore.Authentication=Information

The log then shows lines such as Bearer was not authenticated. Failure message: Token lifetime exceeds Auth:MaxTokenLifetimeMinutes. Personal data in token-validation messages stays hidden. Set the level back to Warning when you're done.

Watch a room live

SSE needs no client library, so it's the quickest way to see what a member receives:

curl -N -H "Authorization: Bearer $TOKEN" "$DOTWIRE/rooms/$ROOM_ID/events"

Send a message from another terminal and it appears as a message event. Add -H "Last-Event-ID: <seq>" to test resuming from a sequence. See Stream room events.

Look at NATS

compose.yaml exposes NATS monitoring on 127.0.0.1:8222. /jsz?streams=true shows the ROOMS and AUDIT streams and their consumers, and /connz lists connected clients. A consumer whose pending count keeps growing means a writer has fallen behind. The same numbers are exported as dotwire.jetstream.* metrics. See Observability.

Verify the audit log

const result = await host.verifyAuditLog(true);

ok: false names the first broken entry in firstInvalidId. See Audit log.

By symptom

dotwire won't start

It stops with an error that names the setting:

ErrorFix
Auth:Issuer and Auth:Audience must be configured.Set Auth__Issuer and Auth__Audience.
Auth:Keys:<kid> must be a public key, not a private key.Use the public key from openssl rsa -pubout.
Auth:Keys:<kid> is not a valid PEM public key.Keep the whole PEM on one double-quoted line, with \n for each line break.
Auth:Keys:<kid> must be at least 2048 bits.Generate a 2048-bit or larger RSA key.
Auth:JwksUrl must use https (or a loopback host)Serve JWKS over https, or set Auth__AllowInsecureJwksUrl=true for local work.
Dotwire:Encryption:ActiveKeyId must name a key present in Dotwire:Encryption:Keys.Set Dotwire__Encryption__Keys__<id> for the id that ActiveKeyId names.
... must use https (or a loopback host); set Dotwire:Webhooks:AllowInsecureUrls=true to override.Use an https webhook URL, or the override for local work.
ConnectionStrings:<name> is not configured.Set the named connection string.

Postgres not ready and NATS not ready warnings with an attempt count are normal while those services start. If the attempts run out, check the connection strings and Nats__Url. With dotnet run against the Compose stack, use 127.0.0.1 as .env.example does, not localhost: Compose publishes those ports on IPv4 loopback only, and localhost can resolve to ::1.

Every request is 401

Work through Read the token first. The usual causes, in order: kid doesn't match a configured key, iss or aud differs from dotwire's config, the token expired, the lifetime is over 60 minutes, or the minting machine's clock is off. With JWKS, a token with a brand new kid is rejected until dotwire has fetched the key. It refetches shortly after it first sees an unknown kid, rate-limited, so publish new keys a few minutes before you sign with them.

403 for a user who should have access

The token is fine, but dotwire's tables disagree. Check getUserRole(userId) returns the role in the token, and getUserRooms(userId) includes the room. Both host SDKs retry once with the user's actual role after a 403. A second 403 means the user really isn't a member.

413, 429 or 503

  • 413: the request body is over Dotwire:MaxRequestBodyBytes (256 KiB). Message content itself is capped lower, at Dotwire:MaxContentBytes, and returns 400 invalid_content.
  • 429 rate_limited: wait for the number of seconds in Retry-After. On an SSE connect, it can also mean the user already holds Dotwire:MaxConnectionsPerUser connections on that node.
  • 503 presend_unavailable: your presend webhook didn't answer in time or answered badly, and its fail policy is Closed. Look for Presend webhook call failed in the log.
  • 503 stream_unavailable: JetStream didn't accept the message. Look for JetStream publish failed and check NATS.
  • 503 audit_unavailable: an admin change couldn't be audited, so it wasn't applied. Retry it; admin calls are safe to repeat.

The hub won't connect, or keeps disconnecting

  • It fails at once from the browser: check the console for a CORS error, which means a missing Cors__AllowedOrigins__0 entry, or transport: 'negotiate' on a cross-origin page. Behind a proxy, make sure it forwards WebSocket upgrades on /hub/rooms.
  • It closes with TooManyConnections: the user holds Dotwire:MaxConnectionsPerUser connections on that node. Look for leaked clients, such as one DotwireClient per component instead of one per app.
  • Subscribe fails with Forbidden: the user isn't a member of that room, or their role doesn't match.
  • It disconnects regularly: the server closes the connection when the token expires. With tokenUrl set, @dotwire/client fetches a fresh token and reconnects. Without it, your getAccessToken must return a fresh token each time it's called.
  • One client keeps being dropped: a connection that can't keep up with its send queue is disconnected, then recovers through gap-fill. This points at a slow network or a blocked main thread on that client.

A message was acked but doesn't show up

  • For other members, live: check they're subscribed to the same room id and are still members. A Live republish failed warning means live delivery missed it. Clients that were connected get it the next time they reconnect, when @dotwire/client fills the gap from history.
  • In history: Postgres catches up about a second after the ack, and history fills the gap from JetStream. JetStream tail read failed ... serving Postgres history only means that top-up failed. Batch insert failed means the Postgres writer is retrying.
  • For one message only, everywhere: look for Failed to decrypt message <seq>. The key it was encrypted under has been removed, or AllowLegacyEnvelopes was set to false while pre-0.3 messages still exist. dotwire skips messages it can't decrypt rather than failing the whole page.

Webhooks aren't working

  • The handler answers 401 invalid_signature: the secrets differ between dotwire and the host SDK, a signature header is missing, the body was parsed and re-serialized before verifying, or the clocks differ by more than five minutes. In .NET, check that you call the WebhookHeaders overload.
  • The handler throws on the first call: webhookSecret / WebhookSecret isn't set. Set it, or allowUnsignedWebhooks for local work only.
  • dotwire logs Webhook URLs are configured without Dotwire:Webhooks:Secret: set Dotwire__Webhooks__Secret to the same value as the host SDK's secret.
  • Postsend events go missing: look for Postsend webhook queue is full or dropped after <n> attempts. Your endpoint is too slow or failing. Postsend never blocks a send, so it drops instead.

A removed user still sees new messages

Removal reaches live connections over NATS within moments. If the broadcast is lost, the log shows Revocation broadcast failed, and the membership sweep closes the access within Dotwire:MembershipSweepSeconds, 60 seconds by default. With a read replica, add the replica lag on top.

Metrics or traces don't show up

  • Nothing arrives at all: inside a container, the default OTEL_EXPORTER_OTLP_ENDPOINT of http://localhost:4317 points at the container itself. Set it to your collector's address, for example http://lgtm:4317 with the Grafana overlay.
  • There are metrics but no traces: traces are off by default. Set Dotwire__EnableTracing=true.
  • A failed request has no database span: spans that recorded an exception are dropped on purpose, because the exception can quote parameter values. The parent request span still carries error.type and the status code.
  • JetStream panels are empty or a gauge disappears: only All and Api nodes report them, every 30 seconds. A gap means a poll failed. Look for JetStream metrics poll failed for <stream> in the log and check NATS.
  • Some panels stay empty: webhook and rejection metrics appear only once something happens, such as the first presend call or the first rejected connect.

Still stuck?

Search or open an issue on GitHub. Include the dotwire version, the node role, the failing request and response status, and the relevant log lines. Never include tokens, keys or message content.