Fixes#30156
This adds a repro of the linked issue. I fixed it by adding a timeout
when issuing the call to unsubscribe.
Co-authored-by: lightclient <14004106+lightclient@users.noreply.github.com>
Here we add distinct error messages for network timeouts and JSON parsing errors.
Note this specifically applies to HTTP connections serving a single RPC request.
Co-authored-by: zhiqiangxu <652732310@qq.com>
Co-authored-by: Felix Lange <fjl@twurst.com>
* rpc: add more test cases for arg types #29006
* rpc: add more test cases for arg types #29006
---------
Co-authored-by: Andrei Kostakov <bps@dzen.ws>
It turns out that encoding json.RawMessage is slow because
package json basically parses the message again to ensure it is valid.
We can avoid the slowdown by encoding the entire RPC notification once,
which yields a 30% speedup.
The String() version of BlockNumberOrHash uses decimal for all block numbers, including negative ones used to indicate labels. Switch to using BlockNumber.String() which encodes it correctly for use in the JSON-RPC API.
Co-authored-by: Adrian Sutton <adrian@oplabs.co>
This change adds a configurable limit to websocket message.
---------
Co-authored-by: tylerni7 <tylerni7@gmail.com>
Co-authored-by: Martin Holst Swende <martin@swende.se>
We're trying a new named pipe library, which should hopefully fix some occasional failures in CI.
---------
Co-authored-by: Martin Holst Swende <martin@swende.se>
Co-authored-by: Felix Lange <fjl@twurst.com>
This should fix#27726. With enough load, it might happen that the SetPongHandler
callback gets invoked before the call to SetReadDeadline is made in pingLoop. When
this occurs, the socket will end up with a 30s read deadline even though it got the pong,
which will lead to a timeout.
The fix here is processing the pong on pingLoop, synchronizing with the code that
sends the ping.
Co-authored-by: Felix Lange <fjl@twurst.com>
Package rpc uses cgo to find the maximum UNIX domain socket path
length. If exceeded, a warning is printed. This is the only use of cgo in this
package. It seems excessive to depend on cgo just for this warning, so
we now hard-code the usual limit for Linux instead.
---------
Co-authored-by: Koichi Shiraishi <zchee.io@gmail.com>
Co-authored-by: Felix Lange <fjl@twurst.com>
This adds two ways to check for subscription support. First, one can now check
whether the transport method (HTTP/WS/etc.) is capable of subscriptions using
the new Client.SupportsSubscriptions method.
Second, the error returned by Subscribe can now reliably be tested using this
pattern:
sub, err := client.Subscribe(...)
if errors.Is(err, rpc.ErrNotificationsUnsupported) {
// no subscription support
}
---------
Co-authored-by: zhiqiangxu <652732310@qq.com>
Co-authored-by: Felix Lange <fjl@twurst.com>
This changes the RPC server to ignore methods using *context.Context as parameter
and *error as return value type. Methods with such types would crash the server when
called.
Co-authored-by: Stephen Guo <stephen.fire@gmail.com>