Netty framework 사용하여 운영중이 어플리케이션이 있다.
Server 와 Client 간 통신 중 간혈적으로 끊기는 현상 때문에 디버깅 로깅으로 확인을 해야하는 상황이 생김..
addLast 메소드에 new LoggingHandler(LogLevel.DEBUG) 추가해 주면 로그를 확인할 수 있다.
@Override
public void initChannel(SocketChannel ch) throws Exception {
ChannelPipeline pipeline = ch.pipeline();
if (sslCtx != null) {
pipeline.addLast(sslCtx.newHandler(ch.alloc(), ObjectEchoClient.HOST, ObjectEchoClient.PORT));
pipeline.addLast(new LoggingHandler(LogLevel.DEBUG));
}
pipeline.addLast(
new ObjectEncoder(),
new ObjectDecoder(ClassResolvers.cacheDisabled(null)),
new ObjectEchoClientHandler());
}
위에 것을 추가해 주면 아래와 같은 결과를 로그로 확인할수 있다.
DEBUG io.netty.util.internal.logging.Slf4JLogger.debug(Slf4JLogger.java:71) - [id: 0x98830200, /127.0.0.1:9881 => /127.0.0.1:5002] FLUSH
DEBUG io.netty.util.internal.logging.Slf4JLogger.debug(Slf4JLogger.java:81) - [id: 0x98830200, /127.0.0.1:9881 => /127.0.0.1:5002] HANDSHAKEN: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
DEBUG io.netty.util.internal.logging.Slf4JLogger.debug(Slf4JLogger.java:71) - [id: 0x98830200, /127.0.0.1:9881 => /127.0.0.1:5002] USER_EVENT: SslHandshakeCompletionEvent(SUCCESS)
ERROR client.logging.LoggingHandler.userEventTriggered(LoggingHandler.java:248) - [id: 0x98830200, /127.0.0.1:9881 => /127.0.0.1:5002] USER_EVENT: SslHandshakeCompletionEvent(SUCCESS)
DEBUG io.netty.util.internal.logging.Slf4JLogger.debug(Slf4JLogger.java:71) - [id: 0x98830200, /127.0.0.1:9881 => /127.0.0.1:5002] RECEIVED(139B)
+-------------------------------------------------+
| 0 1 2 3 4 5 6 7 8 9 a b c d e f |
+--------+-------------------------------------------------+----------------+
|00000000| 00 00 00 87 05 73 72 01 00 13 6a 61 76 61 2e 75 |.....sr...java.u|
|00000010| 74 69 6c 2e 48 61 73 68 74 61 62 6c 65 78 70 3f |til.Hashtablexp?|
|00000020| 40 00 00 00 00 00 08 77 08 00 00 00 0b 00 00 00 |@......w........|
|00000030| 02 74 00 05 47 55 42 55 4e 74 00 0e 43 6f 6e 6e |.t..GUBUNt..Conn|
|00000040| 65 63 74 5f 53 65 72 76 65 72 74 00 0e 52 45 53 |ect_Servert..RES|
|00000050| 55 4c 54 5f 4d 45 53 53 41 47 45 74 00 2c 57 65 |ULT_MESSAGEt.,We|
+--------+-------------------------------------------------+----------------+
INFO client.logging.LoggingHandler.logMessage(LoggingHandler.java:332) - [id: 0x98830200, /127.0.0.1:9881 => /127.0.0.1:5002] RECEIVED(139B)
'개발경험 및 메모 > Netty' 카테고리의 다른 글
Netty - handshake timed out 에러 (2) (0) | 2020.07.03 |
---|---|
Netty - handshake timed out 에러 (1) (0) | 2020.06.23 |
Netty Error - adjusted frame length exceeds 1048576 (0) | 2020.06.21 |
최근댓글