105 lines
4.0 KiB
Markdown
105 lines
4.0 KiB
Markdown
# WebSocket Test Server
|
|
|
|
This is a simple WebSocket test tool designed for verifying connections, testing latency, and measuring Round-Trip Time (RTT).
|
|
|
|
---
|
|
|
|
- [WebSocket Test Server](#websocket-test-server)
|
|
- [How it works:](#how-it-works)
|
|
- [Logging:](#logging)
|
|
- [Setup \& Installation:](#setup--installation)
|
|
- [How to Run](#how-to-run)
|
|
- [Windows](#windows)
|
|
- [Linux / MacOS](#linux--macos)
|
|
- [Manual Execution (Advanced)](#manual-execution-advanced)
|
|
- [Notes](#notes)
|
|
- [Recommended Custom Test Servers](#recommended-custom-test-servers)
|
|
- [Acknowledgements:](#acknowledgements)
|
|
|
|
---
|
|
|
|
## How it works:
|
|
- **Dual Mode**: The tester can connect to either the Twitch IRC WebSocket server or a custom WebSocket server (e.g. an echo test server, see [Recommended CTS](#recommended-custom-test-servers) for more).
|
|
- **Interactive Start**: Run the starter script [start.bat](#windows) on Windows or [start.sh](#linux--macos) on Linux and choose the run mode and target directly in the terminal.
|
|
- **Ping Cycle**: Once connected, the tester will send 5 test PINGs (1 every 5 seconds) to the chosen server:
|
|
- *Custom servers*: Sends a `PING` message and waits for the echo response to measure RTT (Real-Time-Text).
|
|
- *Twitch*: Sends `PING :tmi.twitch.tv` and logs the incoming Twitch server data.
|
|
|
|
---
|
|
|
|
## Logging:
|
|
- All sent and received messages, including timestamps and RTTs (in milliseconds), are tracked in real-time.
|
|
- After 5 successful ping cycles, a log file is automatically created in the "logs" folder, containing all relevant details.
|
|
- The program displays the final log file path and exit automatically after 3 seconds.
|
|
|
|
---
|
|
|
|
## Setup & Installation:
|
|
|
|
1. **Install Node.js**:
|
|
- Download and install [**Node.js**](https://nodejs.org/)
|
|
- Verify installation by running `node -v` and `npm -v` in your terminal.
|
|
|
|
2. **Prepare the Project**:
|
|
- Clone or download this repository and open a terminal in the project folder.
|
|
|
|
3. **Install dependencies**:
|
|
- Run the following command to install the required packages:
|
|
```bash
|
|
npm install
|
|
```
|
|
|
|
---
|
|
|
|
## How to Run
|
|
|
|
Instead of typing long commands, use the provided interactive starter scripts:
|
|
|
|
### Windows
|
|
Double-click `start.bat`or run it via CMD with:
|
|
```cmd
|
|
start.bat
|
|
```
|
|
|
|
### Linux / MacOS
|
|
Firstly you have to give the `start.sh` execution permissions with:
|
|
```bash
|
|
chmod +x start.sh
|
|
```
|
|
|
|
Then you can start the script with:
|
|
```bash
|
|
./start.sh
|
|
```
|
|
|
|
### Manual Execution (Advanced)
|
|
If you prefer to bypass the interactive scripts, you can run the node application directly:
|
|
- Custom server mode (default): `node index.js custom [custom_url]`
|
|
- Twitch mode: `node index.js twitch [channel_name]`
|
|
|
|
### Notes
|
|
- **Defaults**: If you leave the `target` blank in custom mode, it will automatically fallback to `wss://echo.websocket.org`
|
|
- **Scope**: This tester is intended purely for development and network diagnostics. It does **NOT** interact with Twitch chat features beyond authentication and standard PING/PONG messages.
|
|
|
|
---
|
|
|
|
## Recommended Custom Test Servers
|
|
|
|
If you want to test the `custom` mode with different public endpoints, you can use these reliable and free WebSocket echo services:
|
|
|
|
- **`wss://echo.websocket.org`** (Default)
|
|
- *Provider:* Built-in fallback
|
|
- *Behavior:* Standard high-availability echo server that mirrors back any text or PING sent to it.
|
|
- **`wss://echo.websocket.in`**
|
|
- *Provider:* PieSocket
|
|
- *Behavior:* A fast and secure public testing endpoint, ideal for checking raw text frame stability.
|
|
- **`wss://ws.postman-echo.com/raw`**
|
|
- *Provider:* Postman
|
|
- *Behavior:* Part of Postman's official utility stack. It returns an exact copy of the sent payloads and is perfect for latency testing.
|
|
|
|
*Note: Make sure your firewall or network security settings allow outgoing connections on port 443 (SSL) for these addresses.*
|
|
|
|
---
|
|
|
|
## Acknowledgements:
|
|
Thank you for using this tester! I hope it helps you quickly and reliably test your WebSocket servers. Feedback, improvements, or contributions are always welcome. Happy testing! |