Skip to content

Commit

Permalink
Stability (#324)
Browse files Browse the repository at this point in the history
* propagate rootcause of JsonRpcException
* increase pool size
* Log WsConnectionImpl exceptions
  • Loading branch information
a10zn8 authored Oct 24, 2023
1 parent 8988035 commit 5157d6f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ open class WsConnectionImpl(
}
onMessage(msg)
} catch (t: Throwable) {
log.warn("Failed to process WS message. ${t.javaClass}: ${t.message}. Message: ${String(it)}")
log.warn("Failed to process WS message", t)
Mono.empty()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@ open class JsonRpcException(
val error: JsonRpcError,
val upstreamId: String? = null,
writableStackTrace: Boolean = true,
) : Exception(error.message, null, true, writableStackTrace) {
cause: Throwable? = null,
) : Exception(error.message, cause, true, writableStackTrace) {

constructor(id: Int, message: String) : this(JsonRpcResponse.NumberId(id), JsonRpcError(-32005, message))

constructor(id: Int, message: String, cause: Throwable) : this(JsonRpcResponse.NumberId(id), JsonRpcError(-32005, message), cause = cause)

companion object {
fun from(err: RpcException): JsonRpcException {
val id = err.details?.let {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import io.netty.handler.codec.http.HttpHeaders
import io.netty.handler.ssl.SslContextBuilder
import io.netty.resolver.DefaultAddressResolverGroup
import org.apache.commons.lang3.time.StopWatch
import org.slf4j.LoggerFactory
import reactor.core.publisher.Mono
import reactor.netty.http.client.HttpClient
import reactor.netty.resources.ConnectionProvider
Expand All @@ -50,18 +49,15 @@ class JsonRpcHttpClient(
tlsCAAuth: ByteArray? = null,
) : JsonRpcReader {

companion object {
private val log = LoggerFactory.getLogger(JsonRpcHttpClient::class.java)
}

private val parser = ResponseRpcParser()
private val httpClient: HttpClient

init {
val connectionProvider = ConnectionProvider.builder("dshackleConnectionPool")
.maxConnections(1000)
.pendingAcquireMaxCount(5000)
.maxConnections(1500)
.pendingAcquireMaxCount(10000)
.build()

var build = HttpClient.create(connectionProvider)
.compress(true)
.resolver(DefaultAddressResolverGroup.INSTANCE)
Expand Down Expand Up @@ -152,7 +148,7 @@ class JsonRpcHttpClient(
val err = when (t) {
is RpcException -> JsonRpcException.from(t)
is JsonRpcException -> t
else -> JsonRpcException(key.id, t.message ?: t.javaClass.name)
else -> JsonRpcException(key.id, t.message ?: t.javaClass.name, cause = t)
}
// here we're measure the internal errors, not upstream errors
metrics.fails.increment()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ class NativeCallSpec extends Specification {
nativeCall.rpcReaderFactory = Mock(RpcReaderFactory) {
1 * create(_) >> Mock(RpcReader) {
1 * read(new JsonRpcRequest("eth_test", [], 10)) >> Mono.error(
new JsonRpcException(JsonRpcResponse.Id.from(12), new JsonRpcError(-32123, "Foo Bar", "Foo Bar Baz"), null, true)
new JsonRpcException(JsonRpcResponse.Id.from(12), new JsonRpcError(-32123, "Foo Bar", "Foo Bar Baz"), null, true, null)
)
}
}
Expand Down

0 comments on commit 5157d6f

Please sign in to comment.