Git Product home page Git Product logo

iola's Introduction

๐Ÿ”„ iola

license npm downloads

Table of contents (click to open)

Description

iola - a command-line socket client with REST API. It helps to work with socket servers using your favorite REST client.

iola tries to simplify socket server testing and support the most popular socket clients. The main way to interact with the tool is the REST API. This approach allows you to use the rich functionality of modern REST clients to work with sockets.

The potential of the tool is revealed when using API clients such as Postman, Insomnia, etc. You can manage collections of requests for projects that have socket-based API, use dynamic variables in requests and many other features supported by these clients.

Features:

  1. Allows reading and sending messages via REST API
  2. Logs all socket events in the console
  3. Has Swagger UI for REST API
  4. Works on Linux, macOS and Windows

Supported clients:

  1. WebSocket
  2. Socket.IO
  3. TCP
  4. Unix socket

Installation

Via npm (for all platforms where Node.js >= 12 is installed).

$ npm install -g iola

Via homebrew (Linux, macOS).

$ brew tap pvarentsov/iola
$ brew install iola

Via scoop (Windows).

$ scoop bucket add iola https://github.com/pvarentsov/scoop-iola.git
$ scoop install iola

Or download standalone binary from releases (Linux, macOS, Windows).

Usage

CLI

$ iola --help

iola - a socket client with REST API

Usage: iola [options] [command]

Options:
  --version                         Display version
  --help                            Display help

Commands:
  websocket|ws [options] <address>  Run websocket client
  socketio|io [options] <address>   Run socket.io client
  tcp [options] <address>           Run tcp client
  unix [options] <address>          Run unix client
  help [command]                    Display help for command

API:
  GET  /messages                    Get message list
  GET  /messages/{id}               Get message by id
  POST /messages                    Send message 
  GET  /swagger                     Get swagger

REST API

Swagger UI:

Get message:


Get message list:


Send any data:



Send binary data (uint8 array):


Clients

All socket clients have the next options:

--api-port <port> Set API port.
Default value: 3000.
--api-host <host> Set API host.
Default value: 127.0.0.1.
--binary-encoding <encoding> Encode sent and received binary messages for more readability.
Supported encodings: ascii, utf8, base64, hex.
--no-emoji Disable emoji in the console.

WebSocket

$ iola help websocket

Usage: iola websocket|ws [options] <address>

Run websocket client

Options:
  -ap, --api-port <port>             Set api port (default: "3000")
  -ah, --api-host <host>             Set api host (default: "127.0.0.1")
  -h, --header <key:value...>        Set http headers
  -rt, --reply-timeout <timeout>     Set reply timeout in ms (default: "1000")
  -be, --binary-encoding <encoding>  Set binary encoding (choices: "ascii","utf8","base64","hex")
  -ne, --no-emoji                    Disable emoji
  --help                             Display help

Examples:
  $ iola websocket ws://127.0.0.1:8080
  $ iola ws ws://127.0.0.1:8080/?token=secret
  $ iola ws ws://127.0.0.1:8080 --header authorization:"Bearer token"
  $ iola websocket ws://127.0.0.1:8080 --binary-encoding utf8
  $ iola websocket ws://127.0.0.1:8080 --reply-timeout 3000 --no-emoji
message formats
  • string
  • json
  • byte-array
http headers

You can pass http headers using --header <key:value...> option. Examples:

  • iola ws ws://127.0.0.1:8080 --header authorization:"Bearer token"
  • iola ws ws://127.0.0.1:8080 -h content-type:application/json -h content-length:42

server reply

You can pass the RequestId to the request with json data in order to await the server reply with such RequestId in the reply data.


RequestId field can be one of the following:

  • requestId
  • request_id
  • reqId
  • req_id
  • traceId
  • trace_id

Default reply timeout is 1000 ms. To change it you can set --reply-timeout <timeout> option.

Socket.IO

iola relies on Socket.IO v4. Please check a version compatibility.

$ iola help socketio
 
Usage: iola socketio|io [options] <address>

Run socket.io client

Options:
  -ap, --api-port <port>             Set api port (default: "3000")
  -ah, --api-host <host>             Set api host (default: "127.0.0.1")
  -h, --header <key:value...>        Set http headers
  -a, --auth <key:value...>          Set authentication payload
  -t, --transport <transport>        Set transport (choices: "polling","websocket")
  -rt, --reply-timeout <timeout>     Set reply timeout in ms (default: "1000")
  -be, --binary-encoding <encoding>  Set binary encoding (choices: "ascii","utf8","base64","hex")
  -ne, --no-emoji                    Disable emoji
  --help                             Display help

Examples: 
  $ iola socketio http://127.0.0.1:8080 
  $ iola io http://127.0.0.1:8080/?token=secret --transport websocket
  $ iola io http://127.0.0.1:8080 --header authorization:"Bearer token"  
  $ iola io http://127.0.0.1:8080 --auth user:iola --auth pass:qwerty1
  $ iola socketio http://127.0.0.1:8080 --binary-encoding utf8 
  $ iola socketio http://127.0.0.1:8080 --reply-timeout 3000 --no-emoji
message formats
  • string
  • number
  • boolean
  • null
  • json
  • byte-array
transport

Client supports "websocket" and "polling" transports. It tries to use "websocket" first, if available.

You can explicitly set the type of transport using --transport <transport> option.

http headers

You can pass http headers using --header <key:value...> option. Examples:

  • iola io http://127.0.0.1:8080 --header authorization:"Bearer token"
  • iola io http://127.0.0.1:8080 -h content-type:application/json -h content-length:42

auth

Socket.IO client can send credentials with the auth option.

You can set the auth payload using --auth <key:value...> option. Examples:

  • iola io http://127.0.0.1:8080 --auth user:iola --auth pass:qwerty1
  • iola io http://127.0.0.1:8080 --a token:"super secret"

send data

Send any data


Send binary data


server reply

Socket.IO supports server replies. This feature is named acknowledgements.


Default reply timeout is 1000 ms. To change it you can set --reply-timeout <timeout> option.

TCP & Unix socket

TCP and Unix socket clients have the same api.

TCP

$ iola help tcp
 
Usage: iola tcp [options] <address>

Run tcp client

Options:
  -ap, --api-port <port>             Set api port (default: "3000")
  -ah, --api-host <host>             Set api host (default: "127.0.0.1")
  -s, --sync                         Enable sync mode
  -rt, --reply-timeout <timeout>     Set reply timeout in ms (sync mode only) (default: "1000")
  -be, --binary-encoding <encoding>  Set binary encoding (choices: "ascii","utf8","base64","hex")
  -ne, --no-emoji                    Disable emoji
  --help                             Display help

Examples: 
  $ iola tcp 127.0.0.1:8080
  $ iola tcp 127.0.0.1:8080 --sync
  $ iola tcp 127.0.0.1:8080 --binary-encoding utf8 
  $ iola tcp 127.0.0.1:8080 --no-emoji

Unix socket

$ iola help unix
 
Usage: iola unix [options] <address>

Run unix client

Options:
  -ap, --api-port <port>             Set api port (default: "3000")
  -ah, --api-host <host>             Set api host (default: "127.0.0.1")
  -s, --sync                         Enable sync mode
  -rt, --reply-timeout <timeout>     Set reply timeout in ms (sync mode only) (default: "1000")
  -be, --binary-encoding <encoding>  Set binary encoding (choices: "ascii","utf8","base64","hex")
  -ne, --no-emoji                    Disable emoji
  --help                             Display help

Examples: 
  $ iola unix ./unix.sock
  $ iola unix ./unix.sock --sync
  $ iola unix ./unix.sock --binary-encoding utf8 
  $ iola unix ./unix.sock --no-emoji

Clients support async and sync modes and use async mode by default.

In async mode, the client and the server exchange messages independently within one connection.

Sync mode uses a request/response protocol. The client opens a new connection for each request, the server responds. The connection is closed either on the server side after a successful response or by a timeout on the client side.

message formats
  • byte-array
sync mode

To enable sync mode need to set --sync option.

server reply

Server replies are supported only in sync mode. If the server does not close the connection, the client will close it on its own during the reply timeout.


Default reply timeout is 1000 ms. To change it you can set --reply-timeout <timeout> option.

License

This project is licensed under the MIT License.

iola's People

Contributors

dependabot[bot] avatar pvarentsov avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.