Netty WebSocket

Theory


Server


Client


Error

io.netty.handler.ssl.NotSslRecordException: not an SSL/TLS record

在Netty中,如果开启了https,但是你使用http请求来发送请求,那么会打印一个SSL/TLS异常

javax.net.ssl.SSLException: Received fatal alert: handshake_failure

PooledUnsafeDirectByteBuf(ridx: 0, widx: 50, cap: 50)

https://caorong.github.io/2016/08/27/netty-hole/

An exceptionCaught() event was fired, and it reached at the tail of the pipeline. It usually means the last handler in the pipeline did not handle the exception.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
class WsErrorHandler(private val name: String = "") : ChannelHandler {
companion object {
private val logger = LoggerFactory.getLogger(WsErrorHandler::class.java)
}

override fun handlerAdded(handlerContext: ChannelHandlerContext?) {

}

override fun exceptionCaught(handlerContext: ChannelHandlerContext?, error: Throwable?) {
logger.error("exceptionCaught(): $name", error)
}

override fun handlerRemoved(handlerContext: ChannelHandlerContext?) {
}

}

pipeline.addLast(WsErrorHandler(name))

Reference