Эта статья доступна только на английском языке.

Типы мониторов

WebSocket monitors

Check that a WebSocket endpoint completes the handshake, optionally send a message and verify the reply, with TLS validation and response-time warnings.

Последнее обновление: 2 мин чтения

API type
websocket
You enter
URL
Runs at most every
Plan minimum
Needs
None

How it works

  1. FastPing opens the URL and sends a WebSocket upgrade request. For wss://, the certificate is validated like an HTTPS check.
  2. The server must answer 101 Switching Protocols with the right Upgrade, Connection and Sec-WebSocket-Accept headers. Redirects are not followed: the URL must be the WebSocket endpoint itself.
  3. If you set a message, FastPing sends it as one text frame. If you set "Must contain", it waits for the server's first text message and looks for that text in it. Pings from the server are answered; binary messages are skipped.
  4. The connection is closed normally (close code 1000).

The response time is the duration of the handshake. The monitor is down when the handshake fails or the expected text is missing, and in warning when the handshake is slower than your threshold or the server accepts none of the subprotocols you asked for.

URLs

Enter wss:// (encrypted) or ws:// URLs. An https:// or http:// URL is converted to wss:// or ws://, and a bare host name becomes wss://host/. Query strings are kept, so endpoints such as /socket?token=… work.

Settings

FieldAPI optionDefaultNotes
URLurlRequiredws:// or wss:// address. An https:// or http:// URL is converted to wss:// or ws://
Message to send (optional)wsMessageNoneUp to 2,000 characters
Must contain (optional)expectedNoneUp to 300 characters
Subprotocol (optional)wsProtocolNoneUp to 200 characters
Timeout (seconds)timeout152 to 60
Warn if slower than (ms)maxMsNone0 to 60,000
Request headersheadersNoneUp to 4,000 characters. One per line, "Name: value".
Check intervalintervalYour plan's minimumFrom your plan's minimum up to 24 hours

Request headers are useful for an Authorization header or a token your endpoint expects. Headers that belong to the WebSocket handshake itself, such as Host, Upgrade or Sec-WebSocket-Key, cannot be overridden. Compression extensions are not offered.

Examples

EndpointSettings
A plain echo or ping endpointMessage {"type":"ping"}, Must contain pong.
GraphQL over WebSocket (graphql-transport-ws)Subprotocol graphql-transport-ws, message {"type":"connection_init"}, Must contain connection_ack.
Socket.IO (Engine.IO v4)URL wss://example.com/socket.io/?EIO=4&transport=websocket, no message, Must contain "sid": the server opens the session by itself.

Common errors

MessageWhat it meansWhat to do
HTTP 200 instead of 101 Switching ProtocolsThe URL answered as a normal web page, not as a WebSocket endpoint.Check the path; proxies must forward the Upgrade and Connection headers.
HTTP 301 instead of 101 Switching Protocols (redirect to …)The endpoint redirects, and WebSocket handshakes do not follow redirects.Use the final URL.
Invalid Sec-WebSocket-Accept: the server did not complete the WebSocket handshakeSomething answered 101 but did not complete the handshake correctly.Usually a misconfigured proxy in front of the server.
First text message does not contain "pong"The server answered with a different message.Check the message your endpoint expects and the reply format.
The server closed the connection before sending a text messageThe server hung up while FastPing waited for the expected reply.Check authentication and the message format.
No subprotocol accepted (requested graphql-transport-ws)Warning: the handshake worked, but without your subprotocol.Check the subprotocol name your server supports.

Test an endpoint now

The free WebSocket tester performs the same handshake once, optionally sends your message and shows the reply.

Остались вопросы?

Напишите нам, и вам ответит живой человек, обычно в течение одного рабочего дня.