这是我的客户端的Handler代码
class RobotHandler : ChannelInboundHandlerAdapter() {
private val logger = LoggerFactory.getLogger(this.javaClass)
override fun channelRead(ctx: ChannelHandlerContext?, msg: Any?) {
logger.info(msg?.toString())
}
override fun channelActive(ctx: ChannelHandlerContext?) {
val request = DefaultHttpRequest(HttpVersion.HTTP_1_0, HttpMethod.GET, "/robot")
ctx?.writeAndFlush(request)
}
override fun exceptionCaught(ctx: ChannelHandlerContext?, cause: Throwable?) {
cause?.printStackTrace()
ctx?.close()
}
}
这是客户端的代码
@Component
@Order(1)
class RobotNettyClient : ApplicationRunner{
private val logger = LoggerFactory.getLogger(this.javaClass)
override fun run(args: ApplicationArguments?) {