Awesome WebSocket CLient - an interactive command line client for testing websocket servers

Overview

claws demonstration

an Awesome WebSocket CLient

Claws

WebSockets have been on the rise for a long time, but there is no good command line client that allows to interface with websockets without having to deal with barebones interfaces. Claws aims to make testing websockets and interfacing with them easier and more pleasant.

Getting started

You can grab the latest release binary from the releases page. Simply download it, extract it, and run it in a command line.

If you have Go set up, it is easy as running the following command and making sure that $GOPATH/bin (or $GOBIN) is in your PATH. Generally, this should be pretty stable, but keep in mind that it builds on master, so it may break at any point.

go get -v -u howl.moe/claws

Usage

claws [wsURL]

wsURL is an optional websocket URL to connect to once the UI has been initialised.

Once the UI has been initialised, you will be by default in "normal mode": green box with nothing in it. This means you are composing a message to send to the server through the websocket. By pressing Esc, followed by a letter, you can do a variety of actions explained in the following table.

Letter Meaning
i Go to insert mode (also works by pressing the Ins key).
c Create a new WebSocket connection. Will prompt for an URL. If nothing is passed, previous WebSocket URL will be used.
q Close current WebSocket connection.

Quitting is done by pressing Ctrl-C. In previous version, you could press Esc twice to exit, but we decided to remove that because some vim aficionados (myself included) may find themselves panickingly pressing esc and accidentally quitting Claws.

If you want to scroll through the logs, while in Esc mode press the arrow keys, PgUp/PgDown, Home/End. Keep in mind that pressing any of these will disable autoscroll, so new elements from the log won't be shown unless you scroll down.

When you're typing text into the field, you can browse through the history of previous text, even in previous sessions, in a bash-like fashion.

Advanced usage

There are also more actions you can activate using ESC + key, that are generally not used on a day-to-day basis.

Letter Meaning
t Toggle timestamps before messages in console.
j Toggle auto-detection of JSON in server messages and automatic tab indentation.
h View help/welcome screen with quick commands.
R Go into replace/overtype mode (can also be done by pressing Insert a couple of times).

Configuration

Claws stores its configuration file in ~/.config/claws.json. You are welcome to hack it and change values to how you see fit. Here's a list of the values: obvious settings are ignored.

  • Timestamp: a timestamp with which all messages to the console should be prefixed. The defaults can be toggled using the t key in esc mode, although you can also use your own prefix, following Go's system of formatting dates. The default values are an empty string "" or "2006-01-02 15:04:05 ".
  • LastWebsocketURL: URL of the last websocket you connected to. Used when connecting using the c key without specifying an URL.
  • LastActions: 50 most recent messages you sent to the console, used for seeking through history using up and down.

Pipe

Piping allows you to log the messages you send and the messages you receive, or do any kind of pre-processing before they are sent or before they are shown on the console.

Pipes are specified by the Pipe configuration variable. It defaults to null - to set it, create an array containing in the first place a command and then the arguments for it. This should be a command available in your $PATH or an absolute path.

For UNIX system, this means you can do logging effectively using tee. The most basic form of logging may look like this:

"Pipe": {
	"In": ["tee", "-a", "received_messages.log"],
	"Out": ["tee", "-a", "sent_messages.log"]
}

This will append to the given log files the received and sent messages. But it doesn't have to stop there! You can really create any script that may do any pre-processing you want to the messages you receive and those you send. If you intend to write a non-trivial script, here are things that might come useful to know:

  • Any non-zero exit code will show an error on the console.
  • The program should be pretty fast to run, as the message can't be shown until the processing has finished.
  • There are some environment variables which provide information on the connection:
    • CLAWS_PIPE_TYPE: The type of pipe; either in or out.
    • CLAWS_SESSION: UNIX timestamp in microseconds of when the session was started.
    • CLAWS_CONNECTION: UNIX timestamp in microseconds of when the connection was started.
    • CLAWS_WS_URL: WebSocket URL we're connected to.

The sky is the limit here, so you can really do anything you can think of. Here are some examples (feel free to add more with a PR!):

Contributing

Claws is mostly feature-complete, though we have something that might interest you on our issue list. If, instead, you're interested in reporting a bug or asking for a new feature, you can create a new issue. There are no real contribution guidelines, but try to write some good Go code and use go fmt :).

Comments
  • Windows - 10: always : panic: The parameter is incorrect.

    Windows - 10: always : panic: The parameter is incorrect.

            panic: The parameter is incorrect.
            panic: The parameter is incorrect.
    
    goroutine 1 [running]:
    github.com/thehowl/claws/vendor/github.com/nsf/termbox-go.move_cursor(0x2, 0x26)
            /home/travis/gopath/src/github.com/thehowl/claws/vendor/github.com/nsf/termbox-go/termbox_windows.go:592 +0x75 github.com/thehowl/claws/vendor/github.com/nsf/termbox-go.Flush(0xc000000000, 0x0)
            /home/travis/gopath/src/github.com/thehowl/claws/vendor/github.com/nsf/termbox-go/api_windows.go:120 +0x10c
    github.com/thehowl/claws/vendor/github.com/nsf/termbox-go.Close()
            /home/travis/gopath/src/github.com/thehowl/claws/vendor/github.com/nsf/termbox-go/api_windows.go:78 +0x39
    github.com/thehowl/claws/vendor/github.com/jroimartin/gocui.(*Gui).Close(0xc0420f8090)
            /home/travis/gopath/src/github.com/thehowl/claws/vendor/github.com/jroimartin/gocui/gui.go:96 +0x27
    panic(0x67ca40, 0xc0421b0000)
            /home/travis/.gimme/versions/go1.10.linux.amd64/src/runtime/panic.go:505 +0x237
    github.com/thehowl/claws/vendor/github.com/nsf/termbox-go.move_cursor(0x2, 0x26)
            /home/travis/gopath/src/github.com/thehowl/claws/vendor/github.com/nsf/termbox-go/termbox_windows.go:592 +0x75 github.com/thehowl/claws/vendor/github.com/nsf/termbox-go.clear()
            /home/travis/gopath/src/github.com/thehowl/claws/vendor/github.com/nsf/termbox-go/termbox_windows.go:629 +0x121
    
    github.com/thehowl/claws/vendor/github.com/nsf/termbox-go.update_size_maybe()
            /home/travis/gopath/src/github.com/thehowl/claws/vendor/github.com/nsf/termbox-go/termbox_windows.go:451 +0xc5 github.com/thehowl/claws/vendor/github.com/nsf/termbox-go.Clear(0x0, 0x0, 0x0)
            /home/travis/gopath/src/github.com/thehowl/claws/vendor/github.com/nsf/termbox-go/api_windows.go:187 +0x41
    github.com/thehowl/claws/vendor/github.com/jroimartin/gocui.(*Gui).flush(0xc0420f8090, 0x0, 0x0)
            /home/travis/gopath/src/github.com/thehowl/claws/vendor/github.com/jroimartin/gocui/gui.go:423 +0x43
    github.com/thehowl/claws/vendor/github.com/jroimartin/gocui.(*Gui).MainLoop(0xc0420f8090, 0x0, 0x0)
            /home/travis/gopath/src/github.com/thehowl/claws/vendor/github.com/jroimartin/gocui/gui.go:384 +0x22b
    main.main()
            /home/travis/gopath/src/github.com/thehowl/claws/main.go:33 +0x1da
    
    opened by rsrini7 4
  • Fix: gocui.Gui has no field or method Execute

    Fix: gocui.Gui has no field or method Execute

    gocui renamed Execute to Update which broke claws:

    main.go:23: g.Execute undefined (type *gocui.Gui has no field or method Execute)
    

    https://github.com/jroimartin/gocui/commit/6564cfcacb01db61e3a4e983405a598db3e91982#diff-55fd5f4372d25ad4c5728e1929d81bc4

    opened by sl1pm4t 2
  • JSON composing

    JSON composing

    Can be activated with <ESC>J, it enables composing json in the textfield with ease, and it is persistent (like replace mode)

    key=value
    {"key":"value"}
    key="value"
    {"key":"value"}
    key=true
    {"key":true}
    key="true"
    {"key":"true"}
    key=1
    {"key":1}
    key="1"
    {"key":"1"}
    a=a b=b
    {"a":"a","b":"b"}
    [1, 2, 3]
    [1,2,3]
    [a=a, b=b c=c]
    [{"a":"a"},{"b":"b","c":"c"}]
    [a, b, c]
    ["a","b","c"]
    a
    "a"
    a=[1, 2, 3]
    {"a":[1,2,3]}
    

    Edge cases will be figured out as we go

    enhancement 
    opened by thehowl 1
  • Message piping

    Message piping

    Enable with <ESC>p for messages received from server, with <ESC>P for messages sent from client, this disables automatically JSON formatting and JSON composing, and it gives the ability to pipe the messages to a command (to be executed with bash if possible) giving the message in stdin, and receiving what to show on stdout (and an eventual error to be shown with state.Error on stderr).

    enhancement 
    opened by thehowl 0
  • Move to tcell

    Move to tcell

    Due to the fact that we can pretty much replicate the few gocui features we use in probably a few hundreds lines of code, in order to have more control it'd be good to move to tcell, since it also has some pretty nice advantages, such as being more portable and not requiring clever hacks so that code is run on the main thread.

    opened by thehowl 0
Releases(0.4.1)
Owner
Morgan
Microsoft is not an open source company. I'm moving my repos slowly - if you can't find something, click the link below.
Morgan
A tiny command line websocket client written in Go

wsc A simplistic tool for sending and receiving websocket messages from a command line. Mainly useful to test websocket servers. Getting started: $ go

Raphael Simon 49 Jan 12, 2022
API that upgrades connection to use websocket. Contains server and client and testing how they communicate

Websocket Test API How to execute First run server using: make run-server. Then run many client instances with: make run-client. Then start typing in

null 0 Dec 25, 2021
Encrypted-websocket-chat - Encrypted websocket chat using golang

Encrypted websocket chat First version written in python This version should be

Artyom Artamonov 13 Sep 15, 2022
Websocket-chat - A simple websocket chat application

WebSocket Chat App This is a simple chat app based on websockets. It allows user

null 1 Jan 25, 2022
BrisGolang is a Go implementation of the game of briscola using the WebSocket protocol for client/server communication.

BrisGolang BrisGolang is a Go implementation of the game of briscola using the WebSocket protocol for client/server communication. Usage You can play

Calogero Miraglia 0 Nov 1, 2021
Websocket client sample integration (go) for FairOS.

fairos-websocket-client FairOS websocket clients should be an extension on the FairOS OpenAPI specification, with introduction of events for seamless

Fair Data Society 2 Jul 14, 2022
Client Implementation of eosio state-history websocket.

Client Implementation of eosio state-history websocket.

Sw/eden Golang 0 Nov 30, 2022
A fast, well-tested and widely used WebSocket implementation for Go.

Gorilla WebSocket Gorilla WebSocket is a Go implementation of the WebSocket protocol. Documentation API Reference Chat example Command example Client

Gorilla Web Toolkit 18.5k Dec 1, 2022
Turn any program that uses STDIN/STDOUT into a WebSocket server. Like inetd, but for WebSockets.

websocketd websocketd is a small command-line tool that will wrap an existing command-line interface program, and allow it to be accessed via a WebSoc

Joe Walnes 16.6k Nov 30, 2022
proxy your traffic through CDN using websocket

go-cdn2proxy proxy your traffic through CDN using websocket what does it do example server client thanks what does it do you can use this as a library

jm33-ng 42 Nov 15, 2022
Chat bots (& more) for Zoom by figuring out their websocket protocol

zoomer - Bot library for Zoom meetings Good bot support is part of what makes Discord so nice to use. Unfortunately, the official Zoom API is basicall

Christopher Tarry 49 Nov 19, 2022
Tiny WebSocket library for Go.

RFC6455 WebSocket implementation in Go.

Sergey Kamardin 4.8k Nov 27, 2022
Simple example for using Turbos Streams in Go with the Gorilla WebSocket toolkit.

Go Example for TurboStreams over WebSockets Simple example for using Turbos Streams in Go with the Gorilla WebSocket toolkit.

Jan Stamer 23 Jun 8, 2022
Minimal and idiomatic WebSocket library for Go

websocket websocket is a minimal and idiomatic WebSocket library for Go. Install go get nhooyr.io/websocket Highlights Minimal and idiomatic API First

Anmol Sethi 2.4k Nov 28, 2022
:notes: Minimalist websocket framework for Go

melody ?? Minimalist websocket framework for Go. Melody is websocket framework based on github.com/gorilla/websocket that abstracts away the tedious p

Ola 2.6k Nov 22, 2022
A modern, fast and scalable websocket framework with elegant API written in Go

About neffos Neffos is a cross-platform real-time framework with expressive, elegant API written in Go. Neffos takes the pain out of development by ea

Gerasimos (Makis) Maropoulos 477 Nov 22, 2022
Terminal on browser via websocket

Terminal on browser via websocket. Supportted OS Linux Mac

skanehira 146 Nov 23, 2022
run shell scripts by websocket with go lauguage

go_shell_socket run shell scripts by websocket with go lauguage Usage pull project get gin and websocket with go get config config.json file build it

soQ 20 Mar 9, 2022
simpleChatInGo - This is a simple chat that i made for fun asnd learn more about websocket

simpleChatInGo This is a simple chat that i made for fun asnd learn more about websocket deploy For deploy this you only need to run the command : $ d

ranon rat 7 Sep 21, 2022