The WebSocket Transfer Agent

wsta is a cli tool written in rust for interfacing with WebSockets

wsta

The WebSocket Transfer Agent

wsta is a cli tool written in rust for interfacing with WebSockets. wsta has the philosophy of being an easy tool to learn and thus gets out of your way to let you work your UNIX magic directly on the WebSocket traffic. The way wsta does this is to be as pipe-friendly as possible, letting you chain it into complex pipelines or bash scripts as you see fit, or just keep it simple and use it as is.

See the manual or type man wsta for details.

Cool things you can do

Since wsta is really pipe-friendly, you can easily work with your output in a way that suits you. If you have a websocket-service that returns JSON, you might want to have your data printed in a nice, readable format. jq is perfect for that.

Because wsta reads from stdin, it can also be used as an interactive prompt if you wish to send messages to the server interactively.

If you're debugging some nasty problem with your stream, you are probably only interested in frames related to your problem. Good news, grep is here to save the day!

Use wsta to monitor your websocket uptime. Use the --ping option to keep the connection alive, and check the exit code for issues. You can also send the last few messages with POST data for a higher quality alert.

If you need to load test your server over a WebSocket connection, it is simple to write a short bash script to do this. The following example uses a loop to continously send messages to the server and saturate the connection as much as possible. This example could also be ran in parallel as many times as required to add more saturated connections to the load test.

wsta also supports binary data using the --binary argument. When provided, all data read from stdin is assumed to be in binary format. The following simplified example records a binary stream from the microphone and sends it continously to the server, reading the response JSON as it comes in.

For more information on binary mode, see the manual and #5.

Configuration profiles

A neat feature of wsta is the ability to have several separate configuration profiles. Configuration profiles are basically presets of CLI arguments like urls and headers saved to a file for easy reuse at a later point.

If you have web services in different environments, you might for example want to have a foo-dev and foo-prod configuration file. This makes it easy to at a later date connect to foo by simply running wsta -P foo-dev,

These files could be checked into VCS and shared between colleagues.

An example of a configuration file:

See the manual for more information.

Installation

Requirements

Currently the only requirement to run wsta is rust-openssl. If you get an error about a missing ssllib.so or similar, try installing OpenSSL runtime libraries and headers. Have a look at this link for instructions on how to do so.

64-bit Linux

I've set up a download page here that you can get wsta

https://software.opensuse.org/download.html?project=home%3Aesphen&package=wsta

I'm working on getting more distributions, as well as 32-bit into the Open Build Service pipeline, which is what creates the releases on that page. For now, you need a 64-bit system to use that page. If you don't use a 64-bit system, have a look below at binaries or compiling it yourself.

Gentoo Linux

wsta can be found in the Gentoo portage tree as dev-util/wsta. In order to install it, simply run the following command.

emerge dev-util/wsta

Mac OS X

To install on Max OS X, ensure you have homebrew installed, then run the following commands. It's going to take a while, please be patient.

brew tap esphen/wsta https://github.com/esphen/wsta.git
brew install wsta

You can also find binary releases on the releases page.

Other Linux distributions

I only provide so many Linux distros on OBS, and only 64-bit versions. If your computer does not fit into the distros provided, then have a look at the download section of the most recent release, and place the attached binary into your $PATH.

https://github.com/esphen/wsta/releases

Windows

Windows binaries are compiled for each release. Ensure you have a command prompt with GNU libraries, for example the git prompt, and run the provided binary file from there.

You can find binary releases on the releases page.

Compile it yourself

DON'T PANIC. It's really easy to compile and install wsta yourself! Rust provides solid tools like cargo for automating the compilation. If you compile wsta yourself, it should run on all of rust's supported platforms.

# Install the rust language and tools
curl https://sh.rustup.rs -sSf | sh

# Install gcc and OpenSSL on your OS
dnf install -y gcc openssl-devel

# Install wsta to `$HOME/.cargo` or `$CARGO_HOME` if set.
# To change the install path, try setting --root to a directory like /usr/local
cargo install --git https://github.com/esphen/wsta.git

Development setup

Install the rust language and tools.

curl https://sh.rustup.rs -sSf | sh

Run the program

cargo run -- -vvv -I -e ws://echo.websocket.org

In order to generate the man page, groff is needed

make man

If updates to the man page are done, remember to generate the markdown manual afterwards

make wsta.md
Issues

Collection of the latest Issues

JetForMe

JetForMe

2

I tried installing wsta on my M1 MacBook Pro. Dunno if Rust has changed since it was last updated, but I got an error compiling:

esphen

esphen

help wanted
1

I've been getting some feedback from the english-speaking community about the name wsta. Consensus is that it's very difficult at best to pronounce, so I'm considering changing it.

Any suggestions? Feel free to leave a comment. It should be short enough to be a CLI command, and have something to do with ws.

bradleyayers

bradleyayers

1

I've written a server that sends pings messages to clients, in order to detect broken connections, and I'd like to use wsta to interact with it. However it seems that wsta does not send pong messages in response to pings.

In my opinion wsta should (by default) reply to ping messages with pong, by just replying with the ping payload.

The current options for "ping" (e.g. -p) are a little confusing, since they're really just sending plain messages as opposed to ping frames.

fentas

fentas

7

I try to use wsta within docker alpine. For that I installed libssl1.0 as it is required. But if I try to use it I get

Do you know any solution to this? Thanks.

AlexKvM

AlexKvM

enhancement
1

Currently it's not possible, because wsta doesn't handle arrow keys in any way (i.e. it inserts ^[[D and ^[[C instead of navigating). It would be more convenient for editing input text.

johnjelinek

johnjelinek

1

alpine uses musl instead of glibc, it would be much pretty great if wsta could be a static binary. Do you think this might be possible?

Here's what happens if I run wsta in alpine:

lancehunt

lancehunt

1

Cool tool! It would be nice to have subprotocol negotiation baked-in via a -s "mysubprotocol" flag.

This works for the 1st leg of the handshake, but seems to fail to respond to the server's reply: wsta -I -H "Sec-WebSocket-Protocol:mysubprotocl" wss://etc.com

Versions

Find the latest versions by id

0.5.0 - Dec 18, 2016

Release of 0.5.0

  • Add support for setting custom ping message

0.4.1 - Aug 12, 2016

Release of 0.4.1

  • Fixes an argument conflict between -p, --ping and configuration profile's -p. The profile argument is now -P

0.4.0 - Aug 11, 2016

Release of 0.4.0

  • Add support for config files and profiles
  • Use all headers from SetCookie when using --login
  • Add windows support
  • Update dependencies

0.3.0 - Jun 03, 2016

Release of 0.3.0

  • Add support for binary data
  • Only frames are printed to stdout, rest is now stderr

0.2.1 - May 31, 2016

Release of 0.2.1

  • Set Origin header based on WS URL
  • Make exit codes more consistent
  • Update dependencies

0.2.0 - May 08, 2016

Release of 0.2.0

  • Change syntax to be wsta [OPTIONS] URL [MESSAGES ...]
  • Is now quiet by default
  • Add --ping
  • Add --echo
  • Add man page

Also no longer tagged with pre-release.

0.1.0 - May 05, 2016

Initial release. Wsta is mostly functional at this point, but expect bugs.

Information - Updated May 26, 2022

Stars: 618
Forks: 22
Issues: 11

Repositories & Extras

rust-clipboard is a cross-platform library for getting and setting the contents of the OS-level clipboard

It has been tested on Windows, Mac OSX, GNU/Linux, and FreeBSD

rust-clipboard is a cross-platform library for getting and setting the contents of the OS-level clipboard

EventStoreDB Rust Client

EventStoreDB rust gRPC gRPC Client

EventStoreDB Rust Client

Rust CLI template

A quick and dirty CLI boilerplate template for Rust

Rust CLI template

Roctogen: a rust client library for the GitHub v3 API

This client API is generated from the Isahc HTTP client

Roctogen: a rust client library for the GitHub v3 API

Rust CLI Template

Template for creating Rust-based CLI tools

Rust CLI Template

Pure Rust client for YubiHSM 2 devices from Yubico

YubiHSM 2 devices from Documentation

Pure Rust client for YubiHSM 2 devices from Yubico

Google Cloud Rust Client

This repository contains Google Cloud Platform services

Google Cloud Rust Client

Parsec Rust Client

When using the JWT-SVID authentication method, the client will expect the SPIFFE_ENDPOINT_SOCKET environment variable to contain the path of the Workload API endpoint

Parsec Rust Client

A Rust client for connecting to OmniSciDB via its RPC protocol of Thrift

OmniSciDB via its RPC protocol of Cargo, using cargo build

A Rust client for connecting to OmniSciDB via its RPC protocol of Thrift

Cardano Rust CLI

com/clemenshorn/cardano-rust-cli

Cardano Rust CLI

Godot Rust CLI is an easy to incorporate Rust modules into your Godot project

Also keep in mind that the main branch will usually be ahead of the version on GitHub repo

Godot Rust CLI is an easy to incorporate Rust modules into your Godot project
Facebook Instagram Twitter GitHub Dribbble
Privacy