-
Notifications
You must be signed in to change notification settings - Fork 636
Logging websocket connection issues #4896
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Seems you could try pass these 3 functions as the last options params of NewWS cometbft/rpc/jsonrpc/client/ws_client.go Lines 148 to 168 in 227ad25
|
I think it is unlikely that there are incentives to provide an api to assess websocket connection stability within this project so unless there is appetite to address this for users of the default websocket client this issue can be closed. @MMDQE thanks - yes that's definitely doable. my use case is making sure that the client can respond in the case of a faulty websocket connection. The cometbft client will log the error via the logger with this method but imho a better design would be to push onto a channel rather than log so that a client can make decisions about what to do in the case a websocket connection is faulty. I made a start on a prototype here |
Bug Report
Setup
CometBFT version (use
cometbft version
orgit rev-parse --verify HEAD
if installed from source):v1.0.0
Have you tried the latest version: yes/no
Yes tried HEAD
ABCI app (name for built-in, URL for self-written if it's publicly available):
n/a
Environment:
go mod
What happened?
When using
rpchttp.New
to connect to an rpc endpoint and websocket connection, the default settings passed to the underlying gorilla websocket connection make it hard for a client using therpchttp.New
method to understand if the websocket connection is healthy or not. This can lead to dead connections with no logging or information available to the application.cometbft/rpc/jsonrpc/client/ws_client.go
Lines 23 to 28 in ce344cc
These settings as per the comments lead to the websocket connection blocking forever and sending no pings
cometbft/rpc/jsonrpc/client/ws_client.go
Lines 71 to 78 in ce344cc
Furthermore even if you pass a logger through to the client there is no easy way to understand if a connection is unhealthy.
This can lead to clients thinking a connection is healthy but in fact it is dead and events are missed.
What did you expect to happen?
I would expect a client using
rpchttp.New
to have some way of understand if a Websocket connection is healthy and being able to act on it. This could mean adjusting at least the ping interval, reconnecting and logging if it has passed. Ideally anyone using the rpchttp client would be able to override the defaults too.NewWS
withinws_client.go
hard codes the defaults. 🧇How to reproduce it
This example is against HEAD which has slog as the logging library and slightly different interfaces for initialising a logger
go run main.go
There should be some way to understand that there was a read or write timeout or that a ping timed out so that a client using the library can make a decision on what to do.
The text was updated successfully, but these errors were encountered: