grpc-spring-boot-starter icon indicating copy to clipboard operation
grpc-spring-boot-starter copied to clipboard

After client(Golang) exit ,Server log error Transport failed

Open ame-yu opened this issue 5 years ago • 1 comments

2019-09-19 14:22:07.032  INFO 4528 --- [-worker-ELG-3-5] i.g.n.NettyServerTransport.connections   : Transport failed

java.io.IOException: 远程主机强迫关闭了一个现有的连接。//translate->an existing connection was forcibly closed by the remote host
	at java.base/sun.nio.ch.SocketDispatcher.read0(Native Method) ~[na:na]
	at java.base/sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:43) ~[na:na]
	at java.base/sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:276) ~[na:na]
	at java.base/sun.nio.ch.IOUtil.read(IOUtil.java:233) ~[na:na]
	at java.base/sun.nio.ch.IOUtil.read(IOUtil.java:223) ~[na:na]
	at java.base/sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:358) ~[na:na]
	at io.netty.buffer.PooledByteBuf.setBytes(PooledByteBuf.java:247) ~[netty-buffer-4.1.39.Final.jar:4.1.39.Final]
	at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:1140) ~[netty-buffer-4.1.39.Final.jar:4.1.39.Final]
	at io.netty.channel.socket.nio.NioSocketChannel.doReadBytes(NioSocketChannel.java:347) ~[netty-transport-4.1.39.Final.jar:4.1.39.Final]
	at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:148) ~[netty-transport-4.1.39.Final.jar:4.1.39.Final]
	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:697) ~[netty-transport-4.1.39.Final.jar:4.1.39.Final]
	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:632) ~[netty-transport-4.1.39.Final.jar:4.1.39.Final]
	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:549) ~[netty-transport-4.1.39.Final.jar:4.1.39.Final]
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:511) ~[netty-transport-4.1.39.Final.jar:4.1.39.Final]
	at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:918) ~[netty-common-4.1.39.Final.jar:4.1.39.Final]
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[netty-common-4.1.39.Final.jar:4.1.39.Final]
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[netty-common-4.1.39.Final.jar:4.1.39.Final]
	at java.base/java.lang.Thread.run(Thread.java:834) ~[na:na]

# client code (Go)
func lsCommand() {
	conn, err := grpc.Dial("127.0.0.1:6565", grpc.WithInsecure())
	if err != nil {
		fmt.Print(err)
		return
	}
	defer conn.Close()
	var cmd = pb.NewCommandClient(conn)
	connCtx, cancel := context.WithTimeout(context.Background(), time.Second)
	defer cancel()
	res, err := cmd.Ls(connCtx, &pb.Empty{})
	if err != nil {
		log.Fatalf("Fatal: %v", err)
	}
	fmt.Print(res)
}
# server code (Kotlin)
@GRpcService
open class Command: CommandGrpc.CommandImplBase() {
    private val logger = Logger.getLogger(this.javaClass.name)

    @Autowired
    var index: Index? = null

    override fun ls(request: Empty?, responseObserver: StreamObserver<SimpleMessage>?) {
        responseObserver?.onNext(SimpleMessage.newBuilder().setMessage(index?.getModuleList()?.joinToString(",")).build())
        responseObserver?.onCompleted()
    }
}

when

After i execute lsCommand and exit the client program

Environment

JDK 11 Spring boot 2.1.8 Go 1.13

ame-yu avatar Sep 19 '19 07:09 ame-yu

And when i used Java as client side for test, there is no error print

ame-yu avatar Sep 19 '19 09:09 ame-yu