WebSocket Client

Enter a ws:// or wss:// URL and press Connect: your browser connects straight to the server, and you can send and log messages. This site’s server relays nothing.

On-deviceNetwork lookupMobile friendly
ConnectionNot connected

A URL starting with ws:// or wss://. The page does not connect when it opens. Only when you press Connect does your browser connect directly to the other side.

Separated by commas or spaces (e.g. chat, v2.json). The one the server picked is shown after connecting.

A browser WebSocket cannot set headers such as Authorization. If the server takes it in the query, enter a name (e.g. token) here and the value below; it is appended to the URL.

Hidden on screen, never saved and never written to the log.

Connection settings (URL etc.) are saved in this browser. The query (after ?), user info and credentials are not saved.

If it does not connect (most common first)

The browser connects straight to the other side. This site’s server does not relay anything.

  1. The server refuses the Origin. The browser always sends this page’s Origin (https://tools.itlibra.com), and a server can refuse an Origin that is not on its allow list, for example with 403. WebSocket is not subject to CORS, but a server can check the Origin header. The browser does not show the reason (the status code); only close code 1006 is visible.
  2. This page is https but the address is ws:// or http:// (mixed content). Use wss://.
  3. The certificate of a wss:// address has a problem (self-signed, expired, wrong host name). Open the same address with https:// in another tab and see whether a certificate warning appears.
  4. The path or port is wrong, or a reverse proxy (nginx etc.) does not pass the Upgrade and Connection headers. If the server answers anything but 101, the browser fails the connection.
  5. The credential is passed the wrong way. A browser WebSocket cannot set headers such as Authorization. Check whether the server expects it in the query, a cookie or a sub-protocol. A cookie may not be sent when the other side is a different site from this one.
  6. The server is down, the port is closed by a firewall, or a corporate network does not let WebSocket through.
Send

Text is sent as UTF-8 text; hex and Base64 are sent as a binary frame.

You cannot send a ping (the browser’s WebSocket API has no way to). The browser answers a server’s ping with a pong by itself. To check that the other side is alive, use a message of your application.

Templates (save what you send and send it again)

Saved only inside this browser (up to 30). Do not put passwords, tokens or other secrets in them.

No saved templates.

Close options (optional)

Leave empty to close without one. Only 1000 and 3000–4999 are allowed.

Up to 123 bytes of UTF-8, and only together with a code.

What the close codes mean (RFC 6455 §7.4)

1005, 1006 and 1015 describe the state of the connection and must not be sent in a frame. 3000–3999 are registered with IANA; 4000–4999 are for applications to define.

  1. 1000 Normal closure
  2. 1001 The other side is going away (server shutdown, page navigation)
  3. 1002 A protocol error was detected
  4. 1003 A kind of data it cannot accept (e.g. binary to a text-only side)
  5. 1005 No code was present (reserved value)
  6. 1006 Closed abnormally (dropped without a code; a failed handshake also shows this)
  7. 1007 The message did not match its type (e.g. text that is not UTF-8)
  8. 1008 A message violated the other side’s policy (a generic code for when no other fits)
  9. 1009 The message was too big
  10. 1010 An extension was required but the server did not return it
  11. 1011 Internal server error
  12. 1015 TLS handshake failure (reserved value)
Message log

Searches event names, topics and bodies (binary as hex and as text).

0 messages logged (0 shown)

No messages yet. Once connected, what you send and receive is listed here (newest first).

Selected message

Select a message in the list to see its content.

How to use

  1. Enter the WebSocket URL (wss://… or ws://…). If needed, add a sub-protocol or a credential to pass in the query.

  2. Press Connect (Ctrl/⌘+Enter also works). Wait until the status says Connected.

  3. Enter what to send as text, hex or Base64 and press Send. Messages you send often can be saved as templates.

  4. Received messages are listed on the right, newest first. Select one to view it as text, formatted JSON or hex. You can search the log and save it as JSON Lines or text.

  5. Press Disconnect to close. You can add a close code and reason.

What it does

Connects straight from your browser

Connecting and messaging happen only between your browser and the other server. This site’s server neither relays nor stores the traffic. Opening the page does not connect; only pressing Connect does.

Explains mixed content before connecting

This page is https, so the browser blocks connections to ws://. When the URL you entered is affected, the tool says why and how to fix it (use wss://) before you connect. localhost and 127.0.0.1 are let through by some browsers, so they get their own note.

Send text, hex or Base64

Text goes out as UTF-8 text; hex (spaces, commas and 0x allowed) and Base64 (URL-safe characters and missing = allowed) go out as a binary frame. One message can be up to 1 MB.

Search, format and save the log

Up to 2,000 messages and about 50 MB in total are logged. Filter by direction and text, view each message as formatted JSON or a hex dump, and save as JSON Lines or text.

Close codes and failure causes

When the connection closes, the close code and reason are logged with the meaning from RFC 6455 §7.4. Causes of a failed connection are explained in order: refused Origin, mixed content, certificate, proxy, how the credential is passed.

Use cases

  • Check that a WebSocket server in development answers with the messages you expect
  • Narrow down why a wss:// address will not connect (Origin, certificate, mixed content, proxy)
  • Send a binary frame written in hex or Base64 and watch the server’s reaction
  • Read the JSON messages a server pushes, formatted
  • Look up what a close code (1000, 1006, 1008 …) means

Supported formats

What you can send

Text (UTF-8)Hex (e.g. de ad be ef)Base64 (standard or URL-safe)

Capability matrix

FeatureSupportNotes
Connect to ws:// and wss://, send and receive text and binarySupported—
Choose sub-protocols and show the one the server pickedSupported—
Close with a code and a reasonSupported—
Save what you send as templates and send it againSupportedStored only inside this browser
Automatic reconnect after a dropPartialOff by default. When on, it has a limit of 1 to 10 attempts
Sending a pingNot supportedThe browser’s WebSocket API has no way to send one. The browser answers a server’s ping with a pong by itself
Connecting with headers such as AuthorizationNot supportedA browser WebSocket cannot set headers. It is for servers that take credentials in the query, a cookie or a sub-protocol
Reaching servers your browser cannot reach (e.g. inside a company network)Not supportedThis site’s server does not relay
Showing the detailed reason of a failed handshakeNot supportedThe browser hides the status code. The tool shows close code 1006 and likely causes

Limits & notes

  • One message is cut at 1 MB (1,048,576 characters of text or 1,048,576 bytes of binary); anything beyond is not logged. Sending is limited to 1 MB as well.
  • The log keeps the newest 2,000 messages and about 50 MB in total, dropping the oldest first. The list shows the newest 300.
  • Sending is limited to 20 per second.
  • While this page is https, a ws:// address cannot be reached (except in browsers that let localhost through).
  • The URL can be up to 2,000 characters and cannot have a # fragment. A sub-protocol is a name of letters, digits and a few symbols.
  • Only the URL (without query and user info), the sub-protocols, the reconnect settings and the templates are saved. The credential is not.
  • JSON formatting reads large numbers as JavaScript numbers, so integers with many digits may be rounded.

Privacy & safety

The only server contacted is the one at the URL you enter. Traffic goes straight from your browser to it; this site’s server neither relays nor stores it. The credential is not saved, and query values are hidden in on-screen connection messages and saved log files. The log disappears when you close the page.

FAQ

Why does my WebSocket close with 1006?
1006 means it closed without a code. It shows up both for a failed connection (refused Origin, certificate, mixed content, proxy) and for a sudden drop after connecting. The browser does not reveal the reason, so go through “If it does not connect” from the top.
Why can’t an https page connect to ws://?
Connecting from an https page to ws:// or http:// would mix insecure traffic into a secure page, so the browser blocks it (mixed content). Use wss:// for the other side. Some browsers let localhost and 127.0.0.1 through.
Does WebSocket have CORS?
WebSocket is not subject to CORS. But the browser sends an Origin header when it connects, and the server can check it and refuse. You cannot change the Origin. Add this page’s Origin to the server’s allow list, or check the server’s Origin check.
Can I connect with an Authorization header?
No. The browser’s WebSocket API cannot set headers. Check whether the server takes authentication in the URL query, a cookie or a sub-protocol. This tool has a field for a value passed in the query.
Can I send a ping?
No. The browser’s WebSocket API has no way to send one. The browser answers a server’s ping with a pong by itself. To check that the other side is alive, send a message of your application (e.g. {"type":"ping"}).
How is this different from the curl code generator or CORS Studio?
This tool actually opens a WebSocket and sends and receives messages. To turn an HTTP request into curl or fetch code, use the curl code generator; to find out why CORS fails, use CORS Studio.

Last updated: