# 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.

- URL: https://tools.itlibra.com/en/websocket-client
- On-device・Network lookup
- Last updated: 2026-11-23

## 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.

## 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

## 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.


## Supported formats

### What you can send

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


## Capability matrix

| Feature | Support | Notes |
| --- | --- | --- |
| Connect to ws:// and wss://, send and receive text and binary | Supported | — |
| Choose sub-protocols and show the one the server picked | Supported | — |
| Close with a code and a reason | Supported | — |
| Save what you send as templates and send it again | Supported | Stored only inside this browser |
| Automatic reconnect after a drop | Partial | Off by default. When on, it has a limit of 1 to 10 attempts |
| Sending a ping | Not supported | The 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 Authorization | Not supported | A 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 supported | This site’s server does not relay |
| Showing the detailed reason of a failed handshake | Not supported | The 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.
