WebSocket monitor
Verify that a WebSocket endpoint completes the handshake and stays connected long enough to write a control ping, catch TLS, upgrade, and proxy failures before your users do.
Chat rooms, live dashboards, trading feeds, collaborative editors, all of them sit on WebSockets. Unlike HTTP, the connection is not torn down after one round-trip; it stays open for minutes or hours. When it fails, it fails silently, the browser's connection drops and reconnect loops spin up. Users only notice when the UI stops updating.
A WebSocket monitor opens a real WebSocket connection on a schedule, writes a control ping after the handshake, and closes the socket. If the handshake fails, the TLS certificate is invalid, the server refuses the upgrade, or the socket dies before the ping write completes, the monitor fires immediately, minutes before anyone would have noticed in the UI. (We do not wait for a pong.)
When to use
- Chat or presence services: Slack-like products, gaming lobbies, multi-user editors.
- Live dashboards: trading platforms, admin consoles streaming metrics.
- IoT backends: devices that maintain a long-lived connection for command-and-control.
- Supplement to HTTP monitoring: your REST API may be fine while the WebSocket upgrade path (
/socket.io,/ws, load-balancer-specific) is broken.
How the check runs
The check tries several ways to prove the endpoint alive at the same time. They all share one timeout, and the first one that proves the endpoint alive decides the result. A target that answers nothing goes down after one timeout, not after one wait per way. A probe that hangs does not hold up a raw connection that answers.
The raw WebSocket connection has four steps:
- Dial, open a TCP/TLS socket to the host.
- Handshake, perform the HTTP Upgrade request (
Upgrade: websocket). The server must respond with HTTP 101. - Ping write, write a WebSocket control frame (opcode 0x9, payload
ping). If the write returns without error this way succeeds; we do not wait for a pong. - Close, the connection is closed.
A failure in steps 1-3 marks the raw connection as failed. If no other way succeeds either, the monitor goes down with the raw connection's specific error message (for example WebSocket connection failed: x509: certificate has expired).
Framework probes. Framework hubs such as SignalR, Socket.IO and SockJS can refuse a raw WebSocket upgrade while being perfectly healthy. So alongside the raw connection the check sends three HTTP probes at the same time:
| Framework | Request | Counts as up when |
|---|---|---|
| SignalR | POST {url}/negotiate?negotiateVersion=1 | 2xx response whose body has connectionId or connectionToken |
| Socket.IO | GET {url}?EIO=4&transport=polling | 2xx response that starts with the 0{ open packet and contains sid |
| SockJS | GET {url}/info | 200 response with a JSON body that has a websocket field |
Probes do not follow redirects. A probe that errors, or gets an answer that does not match, only means "not this framework"; it does not mean down, and the raw connection's result still stands. The probes send the same custom headers as the raw connection. When a probe succeeds, the raw upgrade's result is not awaited, so a hub whose upgrade is broken can still read up.
401 and 403. A hub that requires authentication may answer a probe with 401 or 403. That answer alone does not show the endpoint is alive, because a WAF, CDN or API gateway in front of it gives the same answer when the backend is down. So a 401/403 counts as up only when it carries a sign that it came from the hub's own process:
- SignalR: the response has a
Server: KestrelorX-Powered-By: ASP.NETheader (that is how an ASP.NET host identifies itself), or it is a401with aWWW-Authenticate: Bearerchallenge. ASP.NET's JWT authentication sends that challenge, and nginx, Azure Front Door and Application Gateway pass it on even when they remove theServerheader. A proxy's own 401 page without a Bearer challenge does not count. - Socket.IO: a
400,401or403response carries Engine.IO's own error JSON, for example{"code":4,"message":"Forbidden"}. The code and message must match the pair Engine.IO defines; a gateway's{"message":"Forbidden"}does not count.
Any other 401/403 does not count as up, and that includes the SockJS probe. The raw upgrade's result then decides. If it fails too, the monitor goes down and the error message names the status code (for example ... (HTTP 401) — the endpoint, or a gateway or firewall in front of it, refused the request ...). If the endpoint needs credentials, add a custom header such as Authorization through the customHeaders field of the API.
A SignalR hub that requires authentication, or a gateway in front of it, can also answer 404 to both the negotiate request and the upgrade of an anonymous client. Then no way can prove the endpoint alive and the monitor goes down. To measure the hub itself, add its credentials: an Authorization header, or for SignalR access_token in the URL (when the server is set up to read the token from the query string).
The response time is the time of the way that proved the endpoint alive: the probe request if a framework probe proved it, the upgrade handshake (dial, TLS and the 101) if the raw connection did. The time of ways that failed is not added.
Remembering. The way that answered is remembered per URL, and later checks send only that one request. If the remembered way stops working, the check forgets it and tries all the ways again in the time that is left. Remembering changes how many requests the check sends, never what it concludes.
Creating the monitor
-
On the Monitors page choose Add monitor.
-
Choose WebSocket as the type (some types sit under Show 7 more types).
-
Fill in:
- Display name: e.g.
Chat realtime channel - URL: One of:
ws://host:port/path, plaintextwss://host:port/path. TLS
- Check interval: the minimum depends on your plan. Realtime services typically use 1 minute.
- Timeout (sec) under Alert settings: default 30 s. The raw connection and the probes share it. Raise it if your handshake is slow behind a proxy.
- Display name: e.g.
-
Save with Start monitoring.
The create form accepts only ws:// and wss:// addresses for this type; the API also accepts http:// / https:// and converts them to ws:// / wss:// before dialing.
If you monitor a staging host with a self-signed certificate, after saving turn off the Strict SSL verification switch under Configure → Security & location; leave it on in production.
The web UI has no field for custom headers (for example Authorization or Origin); you set them only through the customHeaders field of the API.
Reaching internal endpoints
By default UptimeWarden only dials public hosts. For intra-cluster WebSocket services, run a custom agent inside the cluster, private network access is enabled per-agent.
What "up" actually tests
The standard WebSocket monitor tests connectivity and the handshake, not application semantics. If the server accepts the upgrade but your chat logic is broken, this monitor still reports up.
For deeper validation, combine:
- A WebSocket monitor (catches handshake / TLS / network issues)
- An HTTP monitor against a
GET /healthstyle endpoint (catches application-level failures)
The two together cover both the transport and the application layer.
Common failure modes
| Error message | Likely cause |
|---|---|
WebSocket connection failed: dial tcp ... connection refused | Service down or not listening on that port. |
... websocket: bad handshake (HTTP <code>) | The server answered the upgrade with something other than 101; the message names the code. Without a code it is usually a load balancer that drops the Upgrade header. |
... (HTTP 404) — nothing at this path accepted the WebSocket upgrade ... | Nothing at the path accepts the upgrade. Check the URL. A SignalR hub that requires authentication, or a gateway in front of it, can also answer 404 to an anonymous client: add an Authorization header or access_token in the URL. |
... (HTTP 400) or (HTTP 426) with a subprotocol hint | A GraphQL/STOMP/MQTT hub refused an upgrade without a subprotocol. See the FAQ below. |
... x509: certificate has expired or is not yet valid | The wss:// certificate rotation went wrong. |
WebSocket ping failed: ... | The handshake succeeded but the server closed the socket before the ping write completed. Often a proxy idle timeout that is too aggressive for the WebSocket lifetime. |
... (HTTP 401) or (HTTP 403) | The endpoint, or a gateway or firewall in front of it, refused the request. If it needs credentials, add a header such as Authorization through customHeaders in the API. |
SLA and notifications
WebSocket monitors use the same notification pipeline as every other type:
- Down: no way proved the endpoint alive. The message shows the raw connection's error.
- Recovery: on the next check one of the ways proves the endpoint alive.
- Multi-location consensus: honoured: a single hiccupping region will not open an incident.
- SLO tracking: supported: configure availability or latency SLOs exactly as you would for HTTP.
FAQ
Q: Can I send a custom message instead of a ping frame? A: Not in the current release. The check writes a single WebSocket control ping; the server is not required to reply with a pong, but if the socket dies during the ping write the monitor goes down.
Q: Will this catch my Socket.IO server?
A: Yes. UptimeWarden now auto-detects framework hubs. A Socket.IO endpoint (/socket.io) is probed with the HTTP polling handshake first; if healthy the monitor is up even though it rejects a raw WebSocket upgrade. You can also add an HTTP monitor on /socket.io/?EIO=4&transport=polling as a fallback.
Q: I have a SignalR or SockJS hub, are those supported?
A: Yes. SignalR hubs are probed via the /negotiate HTTP handshake, SockJS via /info. These frameworks reject a raw WebSocket upgrade but are healthy; UptimeWarden recognizes this and reports them correctly as up. Add the hub's root URL (e.g. wss://api.example.com/chathub) as the monitor. If the hub requires authentication and its 401 does not show that it came from the hub itself (see 401 and 403 above), add the credentials too; otherwise the monitor reads down.
Q: My GraphQL/STOMP/MQTT WebSocket server says "unexpected response"?
A: Those protocols require a subprotocol (Sec-WebSocket-Protocol). UptimeWarden auto-detects from the URL shape (graphql path → graphql-transport-ws, mqtt host/:9001 → mqtt, stomp host → stomp). There is no setting to choose the subprotocol. If it is still rejected, add a custom header named Sec-WebSocket-Protocol to the monitor through the API (customHeaders); an explicit header wins over the automatic choice.
Q: What if the endpoint is actually SSE (Server-Sent Events)?
A: That's HTTP, not WebSocket, it returns text/event-stream. UptimeWarden detects this and suggests switching the monitor type to HTTP; SSE endpoints should be monitored with an HTTP monitor.
Q: Self-signed cert in staging, real cert in production, one monitor for both? A: Create two monitors. Keeping Strict SSL verification on for production protects you against a real certificate expiry; turning it off for staging prevents noise.
Related topics
- Multi-Location Consensus: reduce false alarms
- SLOs & Error Budgets: alert on burn rate, not every failure
- gRPC Monitor: for service-to-service RPC health