A terminal-based WebSocket client built in Rust. This application allows you to connect to WebSocket endpoints, send messages interactively, and receive real-time responses.
- Supports connecting to multiple WebSocket paths:
/echo
– Sends back any message you send./math
– Processes simple mathematical expressions./global-chat
– Connects to a public chatroom.
- Clean terminal interface with real-time message display.
- Interactive input/output, replicating
wscat
behavior. - Graceful connection handling and termination with
/exit
command.
To build and run the client, you need:
- Rust (latest stable version) installed.
If Rust is not installed, follow the Rust installation guide. - Rust Websocket Server running.
-
Clone the repository:
git clone https://github.com/LukaJioshvili20/rust-websocket-client.git cd rust-websocket-client
-
Build the project:
cargo build --release
-
Run the WebSocket Server:
cargo run
-
Clone the repository:
git clone https://github.com/LukaJioshvili20/rust-websocket-client.git cd rust-websocket-client
-
Build the project:
cargo build --release
-
Run the WebSocket client:
cargo run
-
Start the WebSocket client:
cargo run
-
Select a WebSocket Path: Use the arrow keys to navigate and Enter to select:
--- Select a WebSocket Path --- > /echo /math /global-chat
-
Interact:
- After connecting, type your message and press Enter to send.
- Received messages are displayed in real-time.
- Type
/exit
to gracefully close the connection.
Connecting to ws://0.0.0.0:8765/echo...
Connected (press CTRL+C to quit):
hello
hello
this is a test
this is a test
/exiting
Exiting...
Connecting to ws://0.0.0.0:8765/math...
Connected (press CTRL+C to quit):
10 * 2
20
5 + 5
10
Connecting to ws://0.0.0.0:8765/global-chat...
Connected (press CTRL+C to quit):
hello from luka
Hi there!
The project is organized as follows:
.
├── Cargo.toml # Project dependencies and metadata
├── src
│ ├── main.rs # Entry point: menu and WebSocket path selection
│ └── ws_client.rs # WebSocket communication logic
└── README.md # This file
The project uses the following libraries:
- tokio: Async runtime for Rust.
- tokio-tungstenite: WebSocket client implementation.
- futures: Utilities for streams and sinks.
- crossterm: Terminal interface handling.
Contributions are welcome! If you'd like to improve or extend the functionality, feel free to submit a PR or open an issue.
This project is licensed under the MIT License. See LICENSE for details.