ptupitsyn commented on code in PR #1766:
URL: https://github.com/apache/ignite-3/pull/1766#discussion_r1136713039
##########
modules/client-handler/src/main/java/org/apache/ignite/client/handler/ClientInboundMessageHandler.java:
##########
@@ -515,6 +553,18 @@ public void channelReadComplete(ChannelHandlerContext ctx)
{
/** {@inheritDoc} */
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
+ if (cause instanceof SSLException || cause.getCause() instanceof
SSLException) {
+ metrics.sessionsRejectedTlsIncrement();
+ }
+
+ if (cause instanceof DecoderException && cause.getCause() instanceof
IgniteException) {
+ var err = (IgniteException) cause.getCause();
+
+ if (err.code() == HANDSHAKE_HEADER_ERR) {
+ metrics.sessionsRejectedIncrement();
+ }
+ }
+
LOG.warn("Exception in client connector pipeline: " +
cause.getMessage(), cause);
Review Comment:
> Should not log be on top just in case?
I don't think it matters. Metric code is safe.
> what happens if code in this handler throws an exception?
Netty will log it like this:
```
2023-03-15 10:45:46:709 +0200
[WARNING][testSessionsRejected(TestInfo)-srv-worker-1][AbstractChannelHandlerContext]
An exception 'java.lang.ArithmeticException: test' [enable DEBUG level for
full stacktrace] was thrown by a user handler's exceptionCaught() method while
handling the following exception:
io.netty.handler.codec.DecoderException:
org.apache.ignite.lang.IgniteException: IGN-CLIENT-10
TraceId:4f3426fb-22da-48f6-a2cb-fa95abccbe6f Invalid magic header in thin
client connection. Expected 'IGNI', but was ' '.
at
io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:499)
at
io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:290)
at
io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)
at
io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
at
io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
at
io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:286)
at
io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442)
at
io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
at
io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
at
io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
at
io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:440)
at
io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
at
io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
at
io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166)
at
io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:788)
at
io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:724)
at
io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:650)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:562)
at
io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
at
io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at
io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: org.apache.ignite.lang.IgniteException: IGN-CLIENT-10
TraceId:4f3426fb-22da-48f6-a2cb-fa95abccbe6f Invalid magic header in thin
client connection. Expected 'IGNI', but was ' '.
at
org.apache.ignite.internal.client.proto.ClientMessageDecoder.readMagic(ClientMessageDecoder.java:90)
at
org.apache.ignite.internal.client.proto.ClientMessageDecoder.decode(ClientMessageDecoder.java:51)
at
io.netty.handler.codec.LengthFieldBasedFrameDecoder.decode(LengthFieldBasedFrameDecoder.java:333)
at
io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:529)
at
io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:468)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]