GithubHelp home page GithubHelp logo

semrush / ws2http Goto Github PK

View Code? Open in Web Editor NEW
6.0 4.0 3.0 32 KB

JSON-RPC 2.0 Websocket to HTTP backend proxy service.

License: GNU General Public License v3.0

Makefile 2.32% Go 97.68%
websocket-proxy json-rpc2

ws2http's Introduction

ws2http

JSON-RPC 2.0 WebSocket to HTTP proxy.

Requirements

  • Golang 1.5+

Usage

Usage of ./ws2http:
  -c int
        max parallel http requests per host (default 10)
  -h string
        websocket listen address (default "localhost:8090")
  -headers string
        allow set custom http headers to rpc backend via comma (default "Authorization")
  -route value
        mapping from websocket endpoint to http endpoint, like /rpc:http://localhost/rpc (default [])
  -timeout int
        timeout in seconds for http requests (default 20)
  -trace
        enable trace output
  -verbose
        enable debug output

Features

  • Proxies all data from WS to HTTP endpoint
  • Timeout for http requests (default 20)
  • Concurrent http requests to host by session (default 10)
  • Trace logs (requests/responses)
  • Encapsulated http backend errors to JSON-RPC errors (returns -1 * httpStatusCode as error code)
  • Supports multiple endpoints
  • Supports /metrics endpoint as Prometheus handler
  • Supports /debug/conns endpoint as remote connection tracer

Goals

  • shared ws endpoint with internal routing with prefix for methods
  • better interface for /debug/conns
  • support batch requests for metrics and routing
  • rewrite HttpForwarder.Handler into smaller parts
  • expand batch requests

How to run

go get github.com/semrush/ws2http
$GOPATH/bin/ws2http -verbose -route /rpc:http://localhost/rpc/

Examples

var w = new WebSocket("ws://localhost/rpc"); w.onmessage = function(data) { console.log(data); };
w.send('SET Authorization authValue')
w.send('{"jsonrpc":"2.0","method":"Ping","id":"1"}')

ws2http's People

Contributors

sergeyfast avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  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.