Emmanuel Odeke
6e5cd10399
rpc/lib/client: jitter test updates and only to-be run on releases
...
* Updated code with feedback from @melekes, @ebuchman and @silasdavis.
* Added Makefile clause `release` to only run the test on seeing tag
`release` during releases i.e
```shell
make release
```
which will run the comprehensive and long integration-ish tests.
2017-10-25 19:20:55 -07:00
Silas Davis
4cb02d0bf2
Exploit the fact the BaseService's closed Quit channel will keep emitting quit signals to close both readRoutine and writeRoutine
2017-10-25 10:19:18 +01:00
Silas Davis
f6adddb4a8
Replace ResultsCh with ResponsesCh
2017-10-24 17:45:13 +01:00
Silas Davis
01be6fa309
Fix WSClient blocking in the readRoutine after Stop() as it tries to write to ResultsCh
2017-10-24 13:31:24 +01:00
Emmanuel Odeke
5504920ba3
rpc/lib/client: add jitter for exponential backoff of WSClient
...
Fixes https://github.com/tendermint/tendermint/issues/751 .
Adds jitter to our exponential backoff to mitigate a self DDOS
vector. The jitter is a randomly picked percentage of a second
whose purpose is to ensure that each exponential backoff retry
occurs within (1<<attempts) == 2**attempts, but with the delay
each client will have a random buffer time before it tries to
reconnect instead of all at once reconnections that might even
bring back the previous conditions that might have caused the
dial to the WSServer to have failed e.g
* Network outage
* File descriptor exhaustion
* False positives from firewalls
etc
2017-10-24 02:00:20 -07:00
Ethan Buchman
ac2ef9e0ea
Merge pull request #750 from tendermint/feature/cleanup
...
Cleanup of code and code docs
2017-10-23 11:14:15 -04:00
Adrian Brink
036d3b59a3
Address reviews
2017-10-23 11:04:45 -04:00
Adrian Brink
782a836db0
Cleanup of code and code docs
...
This cleans up some of the code in the state package
2017-10-23 11:04:45 -04:00
Silas Davis
3e3d53daef
Make RPCError an actual error and don't swallow its companion data
2017-10-22 15:14:21 +01:00
Anton Kaliaev
aae4e94998
make RPCRequest params not a pointer
...
https://github.com/tendermint/tendermint/pull/724#issuecomment-335362927
2017-10-10 13:50:06 +04:00
Anton Kaliaev
d935a4f0a8
recover from panic in WS JSON RPC readRoutine
...
https://github.com/tendermint/tendermint/pull/724#issuecomment-335316484
2017-10-10 13:48:56 +04:00
Anton Kaliaev
5c331d8276
log a notification to help debug user issues
2017-10-10 13:01:25 +04:00
Anton Kaliaev
13b9de6778
return missing package declaration
2017-10-10 12:48:36 +04:00
Anton Kaliaev
a3adac3787
[rpc] do not try to parse params if they were not provided (Refs #708 )
2017-10-09 13:30:52 +04:00
Anton Kaliaev
3702cb7e7c
restore rpc/lib readme as doc.go (Refs #710 ) [ci skip]
...
I don't want to lose any documentation. Correct me if I am wrong, but we
don't have this docs anywhere else.
2017-10-05 11:44:02 +04:00
Zach Ramsay
136b6a7673
rpc/lib: remove dead files, closes #710
2017-10-04 17:45:15 -04:00
Zach Ramsay
d56b44f3a5
all: no more anonymous imports
2017-10-04 16:40:45 -04:00
Anton Kaliaev
45ff7cdd0c
rewrite ws client to expose a callback instead of a channel
...
callback gives more power to the publisher. plus it is optional
comparing to a channel, which will block the whole client if you won't
read from it.
2017-10-02 13:00:20 -04:00
Alexandre Thibault
ce36a0111a
rpc: subscribe on reconnection ( #689 )
...
* rpc: subscribe on reconnection
* rpc: fix unit tests
2017-10-02 13:00:20 -04:00
Alexandre Thibault
382bead548
rpc: fix client websocket timeout ( #687 )
2017-09-29 13:32:30 +04:00
Anton Kaliaev
f9479b34cb
sleep time should be greater than readTimeout (5 sec)
...
otherwise, we're not testing ping/pongs.
see https://github.com/tendermint/tendermint/pull/687#issuecomment-332494735
2017-09-27 15:44:19 +04:00
Ethan Buchman
ddb3d8945d
p2p: allow listener with no external connection
2017-09-22 10:13:23 -04:00
Anton Kaliaev
f8b152972f
return method not found error
...
if somebody tries to access WS method in non-ws context
2017-09-18 16:36:03 -04:00
Anton Kaliaev
95875c55fc
ID must be present in both request and response
...
from the spec:
This member is REQUIRED.
It MUST be the same as the value of the id member in the Request Object.
If there was an error in detecting the id in the Request object (e.g. Parse error/Invalid Request), it MUST be Null.
2017-09-18 16:36:03 -04:00
Anton Kaliaev
7fadde0b37
check for request ID after receiving it
2017-09-18 16:36:03 -04:00
Anton Kaliaev
e36c79f713
capitalize RpcError
2017-09-18 16:36:03 -04:00
Anton Kaliaev
b700ed8e31
remove check for non-empty message as it should always be present
2017-09-18 16:36:03 -04:00
Anton Kaliaev
f74de4cb86
include optional data field in error object
...
```
data
A Primitive or Structured value that contains additional information about the error.
This may be omitted.
The value of this member is defined by the Server (e.g. detailed error information, nested errors etc.).
```
2017-09-18 16:36:02 -04:00
Anton Kaliaev
6c1572c9b8
fix invalid memory address or nil pointer dereference
2017-09-18 16:36:02 -04:00
Dave Bryson
60a1f49a5c
updated json response to match spec by @davebryson
2017-09-18 16:35:50 -04:00
Ethan Buchman
9dde1a0bd4
rpc: comments
2017-08-25 17:57:09 -04:00
Anton Kaliaev
2fd8496bc1
correct handling of pings and pongs
...
server:
- always has read & write timeouts
- ping handler never blocks the reader (see A)
- sends regular pings to check up on a client
A:
at some point server write buffer can become full, so in order not to
block reads from a client (see
https://github.com/gorilla/websocket/issues/97 ), server may skip some
pongs. As a result, client may disconnect. But you either have to do
that or block the reader. There is no third way.
client:
- optional read & write timeouts
- optional ping/pong to measure latency
2017-08-10 17:53:49 -04:00
Anton Kaliaev
236489aecf
backlog must always have higher priority
2017-08-08 19:03:48 -04:00
Ethan Buchman
797acbe911
ws: small comment
2017-08-08 17:33:17 -04:00
Anton Kaliaev
9b5f21a650
[ws-server] reset readTimeout when we receive something
2017-08-08 16:03:04 -04:00
Anton Kaliaev
8267920749
[ws-client] write normal close message
2017-08-08 16:02:37 -04:00
Anton Kaliaev
6c85e4be4f
change server ping period to be less frequent
...
no need to ping ws every 10 sec
2017-08-08 13:21:59 -04:00
Anton Kaliaev
23a87304cc
add a comment for PingPongLatencyTimer [ci skip]
2017-08-08 13:20:58 -04:00
Anton Kaliaev
c14b39da5f
make RPC server's ping period and pong wait configurable via options
2017-08-07 18:29:55 -04:00
Anton Kaliaev
57eee2466b
make WSClient thread-safe
2017-08-07 17:56:38 -04:00
Anton Kaliaev
5d66d1c28c
fixes from review
2017-08-05 13:11:00 -04:00
Anton Kaliaev
0013053fae
allow to change pong wait and ping period
2017-08-04 10:42:55 -04:00
Anton Kaliaev
1abbb11b44
do not exit from reconnectRoutine!
2017-08-03 22:44:18 -04:00
Anton Kaliaev
54903adeff
add IsReconnecting and IsActive methods
2017-08-03 19:10:15 -04:00
Anton Kaliaev
c08618f7e9
expose latency timer on WSClient
2017-08-03 19:10:14 -04:00
Anton Kaliaev
d578f7f81e
biff up WS client
...
What's new:
- auto reconnect
- ping/pong
- colored tests
2017-08-03 19:10:14 -04:00
Ethan Buchman
0d1fa8e884
fixes from review
2017-06-28 11:12:45 -04:00
Ethan Buchman
e2ed15fa02
rpc: SetWriteDeadline for ws ping. fixes #553
2017-06-26 17:13:39 -04:00
Ethan Buchman
b6031d5f4b
rpc/lib: set logger on ws conn
2017-06-24 21:55:31 -04:00
Ethan Buchman
5c29d7aba9
rpc/lib: test tcp and unix
2017-06-24 21:27:19 -04:00