solution: docs for WebSocket support
This commit is contained in:
26
README.adoc
26
README.adoc
@@ -24,7 +24,7 @@ It automatically verifies their availability and the current status of the netwo
|
|||||||
|
|
||||||
Provides:
|
Provides:
|
||||||
|
|
||||||
- Standard Bitcoin and Ethereum JSON RPC API
|
- Standard Bitcoin and Ethereum JSON RPC API over HTTP and WebSocket
|
||||||
- Enhanced gRPC-based API, with upstream selection, async execution, etc
|
- Enhanced gRPC-based API, with upstream selection, async execution, etc
|
||||||
- **Secure** TLS with optional client authentication
|
- **Secure** TLS with optional client authentication
|
||||||
- Blockchain-aware edge **caching**, in memory and Redis
|
- Blockchain-aware edge **caching**, in memory and Redis
|
||||||
@@ -107,12 +107,12 @@ Which sets the following:
|
|||||||
|
|
||||||
- gRPC access through 0.0.0.0:2449
|
- gRPC access through 0.0.0.0:2449
|
||||||
** TLS security is disabled (_please don't use in production!_)
|
** TLS security is disabled (_please don't use in production!_)
|
||||||
- JSON RPC access through 0.0.0.0:8545
|
- JSON RPC access through 0.0.0.0:8545 (both HTTP and WebsScket)
|
||||||
** proxy requests to Ethereum and Kovan upstreams
|
** proxy requests to Ethereum and Kovan upstreams
|
||||||
** request path for Ethereum Mainnet is `/eth`, `/kovan` for Kovan Testnet, and `/btc` for bitcoin
|
** request path for Ethereum Mainnet is `/eth`, `/kovan` for Kovan Testnet, and `/btc` for bitcoin
|
||||||
** i.e. call Ethereum Mainnet by `POST http://127.0.0.0:8545/eth` with JSON RPC payload
|
** i.e. call Ethereum Mainnet by `POST http://127.0.0.0:8545/eth` with JSON RPC payload
|
||||||
- two upstreams, one for Ethereum Mainnet and another for Kovan Testnet (both upstreams are configured to use Infura endpoint)
|
- two upstreams, one for Ethereum Mainnet and another for Kovan Testnet (both upstreams are configured to use Infura endpoint)
|
||||||
- for Ethereum Mainnet it connects using JSON RPC and Websockets connections,
|
- for Ethereum Mainnet it connects using JSON RPC and WebSocket connections,
|
||||||
- for Bitcoin Mainet only JSON RPC is used
|
- for Bitcoin Mainet only JSON RPC is used
|
||||||
- `${INFURA_USER}` will be provided through environment variable
|
- `${INFURA_USER}` will be provided through environment variable
|
||||||
|
|
||||||
@@ -146,7 +146,7 @@ Tools such as https://github.com/fullstorydev/grpcurl[gRPCurl] can automatically
|
|||||||
|
|
||||||
Alternatively you can connect to port 8545 with traditional JSON RPC requests
|
Alternatively you can connect to port 8545 with traditional JSON RPC requests
|
||||||
|
|
||||||
==== Access using JSON RPC
|
==== Access using JSON RPC over HTTP
|
||||||
|
|
||||||
Dshackle implements standard JSON RPC interface, providing additional caching layer, upstream readiness/liveness checks, retry and other features for building Fault Tolerant services.
|
Dshackle implements standard JSON RPC interface, providing additional caching layer, upstream readiness/liveness checks, retry and other features for building Fault Tolerant services.
|
||||||
|
|
||||||
@@ -165,6 +165,24 @@ curl --request POST \
|
|||||||
{"jsonrpc":"2.0","id":1,"result":"0x72fa5e0181"}
|
{"jsonrpc":"2.0","id":1,"result":"0x72fa5e0181"}
|
||||||
----
|
----
|
||||||
|
|
||||||
|
==== Access using JSON RPC over WebSocket
|
||||||
|
|
||||||
|
Or the same Proxy URL can be accessed through WebSocket
|
||||||
|
|
||||||
|
[source,bash]
|
||||||
|
----
|
||||||
|
websocat ws://localhost:8545/eth
|
||||||
|
----
|
||||||
|
|
||||||
|
Then make RPC calls or subscriptions:
|
||||||
|
|
||||||
|
----
|
||||||
|
> | {"jsonrpc":"2.0", "id": 1, "method": "eth_subscribe", "params": ["newHeads"]}
|
||||||
|
|
||||||
|
< | {"jsonrpc":"2.0","id":1,"result":"1f8"}
|
||||||
|
< | {"jsonrpc":"2.0","method":"eth_subscription","params":{"result":{....},"subscription":"1f8"}}
|
||||||
|
----
|
||||||
|
|
||||||
==== Access using gRPC
|
==== Access using gRPC
|
||||||
|
|
||||||
NOTE: It's not necessary to use gRPC, as Dshackle can provide standard JSON RPC proxy, but Dshackle gRPC interface improves performance and provides additional features.
|
NOTE: It's not necessary to use gRPC, as Dshackle can provide standard JSON RPC proxy, but Dshackle gRPC interface improves performance and provides additional features.
|
||||||
|
|||||||
@@ -62,6 +62,10 @@ a| `upstreams`
|
|||||||
|
|
||||||
=== Enabling JSON RPC proxy
|
=== Enabling JSON RPC proxy
|
||||||
|
|
||||||
|
In addition to the gRPC protocol, Dshackle provides access compatible with Bitcoin and Ethereum JSON RPC.
|
||||||
|
The same server can be accessible as an HTTP JSON RPC and WebSocket JSON RPC.
|
||||||
|
For Ethereum, besides the standard RPC calls, it provides RPC subscriptions with `eth_subscribe` method.
|
||||||
|
|
||||||
.Example proxy:
|
.Example proxy:
|
||||||
[source,yaml]
|
[source,yaml]
|
||||||
----
|
----
|
||||||
@@ -82,7 +86,9 @@ cluster:
|
|||||||
With that configuration Dshackle starts a JSON RPC proxy:
|
With that configuration Dshackle starts a JSON RPC proxy:
|
||||||
|
|
||||||
- JSON RPC server is listening on `0.0.0.0:8080`
|
- JSON RPC server is listening on `0.0.0.0:8080`
|
||||||
- `http://0.0.0.0:8080/eth` provides access to Ethereum API routed to an available upstream
|
- `http://0.0.0.0:8080/eth` (and `ws://0.0.0.0:8080/eth`) provides access to Ethereum API routed to an available upstream
|
||||||
|
|
||||||
|
NOTE: Same URL should be used to access both HTTP RPC and WebSocket RPC
|
||||||
|
|
||||||
.Full configuration:
|
.Full configuration:
|
||||||
[source,yaml]
|
[source,yaml]
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ cache:
|
|||||||
proxy:
|
proxy:
|
||||||
host: 0.0.0.0
|
host: 0.0.0.0
|
||||||
port: 8080
|
port: 8080
|
||||||
|
websocket: true
|
||||||
tls:
|
tls:
|
||||||
enabled: true
|
enabled: true
|
||||||
server:
|
server:
|
||||||
@@ -373,20 +374,26 @@ proxy:
|
|||||||
|
|
||||||
| `host`
|
| `host`
|
||||||
| `127.0.0.0`
|
| `127.0.0.0`
|
||||||
| Host to bind gRPC server
|
| Host to bind HTTP server
|
||||||
|
|
||||||
| `port`
|
| `port`
|
||||||
| `2449`
|
| `8080`
|
||||||
| Port to bind gRPC server
|
| Port to bind HTT server
|
||||||
|
|
||||||
|
| `websocket`
|
||||||
|
| `true`
|
||||||
|
| Enable WebSocket Proxy
|
||||||
|
|
||||||
| `tls`
|
| `tls`
|
||||||
|
|
|
|
||||||
| Setup TLS configuration for the Proxy server. See <<tls>> section
|
| Setup TLS configuration for the Proxy server.
|
||||||
|
See <<tls>> section
|
||||||
|
|
||||||
| `routes`
|
| `routes`
|
||||||
|
|
|
|
||||||
a| Routing paths for Proxy.The proxy will handle requests as `https://${HOST}:${PORT}/${ROUTE_ID}` (or `http://` if TLS is not enabled)
|
a| Routing paths for Proxy.
|
||||||
|
The proxy will handle requests as `https://${HOST}:${PORT}/${ROUTE_ID}` (or `http://` if TLS is not enabled).
|
||||||
|
For WebSocket it's `wss` / `ws`, accordingly.
|
||||||
|===
|
|===
|
||||||
|
|
||||||
.Route config
|
.Route config
|
||||||
@@ -663,14 +670,14 @@ rpc:
|
|||||||
----
|
----
|
||||||
|
|
||||||
| `ws.url`
|
| `ws.url`
|
||||||
| Websocket URL to connect to.
|
| WebSocket URL to connect to.
|
||||||
Optional, but optimizes performance if it's available.
|
Optional, but optimizes performance if it's available.
|
||||||
|
|
||||||
| `ws.origin`
|
| `ws.origin`
|
||||||
| HTTP `Origin` if required by Websocket remote server.
|
| HTTP `Origin` if required by WebSocket remote server.
|
||||||
|
|
||||||
| `ws.basic-auth` + ...
|
| `ws.basic-auth` + ...
|
||||||
| Websocket Basic Auth configuration, if required by the remote server
|
| WebSocket Basic Auth configuration, if required by the remote server
|
||||||
|
|
||||||
| `ws.frameSize`
|
| `ws.frameSize`
|
||||||
| WebSocket frame size limit.
|
| WebSocket frame size limit.
|
||||||
|
|||||||
Reference in New Issue
Block a user