Stability (#324)
* propagate rootcause of JsonRpcException * increase pool size * Log WsConnectionImpl exceptions
This commit is contained in:
@@ -273,7 +273,7 @@ open class WsConnectionImpl(
|
|||||||
}
|
}
|
||||||
onMessage(msg)
|
onMessage(msg)
|
||||||
} catch (t: Throwable) {
|
} 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()
|
Mono.empty()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,10 +22,13 @@ open class JsonRpcException(
|
|||||||
val error: JsonRpcError,
|
val error: JsonRpcError,
|
||||||
val upstreamId: String? = null,
|
val upstreamId: String? = null,
|
||||||
writableStackTrace: Boolean = true,
|
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) : 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 {
|
companion object {
|
||||||
fun from(err: RpcException): JsonRpcException {
|
fun from(err: RpcException): JsonRpcException {
|
||||||
val id = err.details?.let {
|
val id = err.details?.let {
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ import io.netty.handler.codec.http.HttpHeaders
|
|||||||
import io.netty.handler.ssl.SslContextBuilder
|
import io.netty.handler.ssl.SslContextBuilder
|
||||||
import io.netty.resolver.DefaultAddressResolverGroup
|
import io.netty.resolver.DefaultAddressResolverGroup
|
||||||
import org.apache.commons.lang3.time.StopWatch
|
import org.apache.commons.lang3.time.StopWatch
|
||||||
import org.slf4j.LoggerFactory
|
|
||||||
import reactor.core.publisher.Mono
|
import reactor.core.publisher.Mono
|
||||||
import reactor.netty.http.client.HttpClient
|
import reactor.netty.http.client.HttpClient
|
||||||
import reactor.netty.resources.ConnectionProvider
|
import reactor.netty.resources.ConnectionProvider
|
||||||
@@ -50,18 +49,15 @@ class JsonRpcHttpClient(
|
|||||||
tlsCAAuth: ByteArray? = null,
|
tlsCAAuth: ByteArray? = null,
|
||||||
) : JsonRpcReader {
|
) : JsonRpcReader {
|
||||||
|
|
||||||
companion object {
|
|
||||||
private val log = LoggerFactory.getLogger(JsonRpcHttpClient::class.java)
|
|
||||||
}
|
|
||||||
|
|
||||||
private val parser = ResponseRpcParser()
|
private val parser = ResponseRpcParser()
|
||||||
private val httpClient: HttpClient
|
private val httpClient: HttpClient
|
||||||
|
|
||||||
init {
|
init {
|
||||||
val connectionProvider = ConnectionProvider.builder("dshackleConnectionPool")
|
val connectionProvider = ConnectionProvider.builder("dshackleConnectionPool")
|
||||||
.maxConnections(1000)
|
.maxConnections(1500)
|
||||||
.pendingAcquireMaxCount(5000)
|
.pendingAcquireMaxCount(10000)
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
var build = HttpClient.create(connectionProvider)
|
var build = HttpClient.create(connectionProvider)
|
||||||
.compress(true)
|
.compress(true)
|
||||||
.resolver(DefaultAddressResolverGroup.INSTANCE)
|
.resolver(DefaultAddressResolverGroup.INSTANCE)
|
||||||
@@ -152,7 +148,7 @@ class JsonRpcHttpClient(
|
|||||||
val err = when (t) {
|
val err = when (t) {
|
||||||
is RpcException -> JsonRpcException.from(t)
|
is RpcException -> JsonRpcException.from(t)
|
||||||
is JsonRpcException -> 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
|
// here we're measure the internal errors, not upstream errors
|
||||||
metrics.fails.increment()
|
metrics.fails.increment()
|
||||||
|
|||||||
@@ -176,7 +176,7 @@ class NativeCallSpec extends Specification {
|
|||||||
nativeCall.rpcReaderFactory = Mock(RpcReaderFactory) {
|
nativeCall.rpcReaderFactory = Mock(RpcReaderFactory) {
|
||||||
1 * create(_) >> Mock(RpcReader) {
|
1 * create(_) >> Mock(RpcReader) {
|
||||||
1 * read(new JsonRpcRequest("eth_test", [], 10)) >> Mono.error(
|
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)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user