Sorry, I was going to reply with something like that yesterday and things came up. Glad you got it working.
It means I can not use ma servezr more than once However, the server shouldn't die even without the awaitTermination(). Future clients should work fine. If not, that's a bug. On Tue, Jun 28, 2016 at 11:49 PM, Nicolas Vacelet <nicolas.vace...@gmail.com > wrote: > I answer to Myself; > > To correctly close the client, and avoid an exception, one should use > > channel.shutdown.awaitTermination(5, SECONDS) > > > 2016-06-28 15:52 GMT+02:00 <nicolas.vace...@gmail.com>: > >> Hi all, >> >> I am new in protobuff... and I already need some help. >> >> Here a simple sample I have successfuly created, a simple service which >> getData from a server.. >> I get an error (An existing connection was forcibly closed by the remote >> host), just after the client received the final acknowledgement. >> It means I can not use ma servezr more than once :) >> >> I am using, on windows7, >> >> Java 8 >> >> protoc:3.0.0-beta-2 >> >> protoc-gen-grpc-java:0.14.0 >> >> protobuf-maven-plugin 0.5.0 >> >> grpc-netty 0.14.0 >> >> grpc-protobuf 0.14.0 >> >> grpc-stub 0.14.0 >> >> >> >> >> On Client Side, >> >> ManagedChannel channel = ManagedChannelBuilder.forAddress(host, port) >> .usePlaintext(true) >> .build();ViewServiceGrpc.ViewServiceBlockingClient blockingStub = >> ViewServiceGrpc.newBlockingStub(channel); >> blockingStub.getData(); >> >> channel.shutdown(); >> >> >> >> >> On the server Side: >> >> >> >> server = ServerBuilder.forPort(port).addService(ViewServiceGrpc.bindS >> ervice(new ViewServiceGrpc.ViewService() { >> public void getData(View request, StreamObserver<Ack> responseObserver) >> { >> switch (request.getDataCase()) { >> >> responseObserver.onNext(Ack.newBuilder().setAckMessage("ACK_OK").build >> ()); >> responseObserver.onCompleted(); >> } >> >> })).build(); >> server.start(); >> >> >> Everything is OK, except this error on server side >> >> >> juin 28, 2016 3:33:47 PM io.grpc.netty.NettyServerHandler >> onConnectionError AVERTISSEMENT: Connection Error java.io.IOException: >> Une connexion existante a dû être fermée par l’hôte distant at sun.nio.ch >> .SocketDispatcher.read0(Native Method) at sun.nio.ch.SocketDispatcher.re >> ad(SocketDispatcher.java:43) at sun.nio.ch.IOUtil.readIntoNativeBuffer( >> IOUtil.java:223) at sun.nio.ch.IOUtil.read(IOUtil.java:192) at sun.nio.ch >> .SocketChannelImpl.read(SocketChannelImpl.java:380) at io.netty.buffer. >> PooledUnsafeDirectByteBuf.setBytes(PooledUnsafeDirectByteBuf.java:288) >> at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:1054) >> at io.netty.channel.socket.nio.NioSocketChannel.doReadBytes(Nio >> SocketChannel.java:245) at io.netty.channel.nio.AbstractN >> ioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:106) at io. >> netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:527) >> at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized( >> NioEventLoop.java:484) at io.netty.channel.nio.NioEventLoop. >> processSelectedKeys(NioEventLoop.java:398) at io.netty.channel.nio. >> NioEventLoop.run(NioEventLoop.java:370) at io.netty.util.concurrent.Singl >> eThreadEventExecutor$5.run(SingleThreadEventExecutor.java:742) at io. >> netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(D >> efaultThreadFactory.java:145) at java.lang.Thread.run(Thread.java:745) >> juin 28, 2016 3:33:47 PM io.grpc.netty.NettyServerTransport >> notifyTerminated GRAVE: Transport failed java.io.IOException: Une >> connexion existante a dû être fermée par l’hôte distant at sun.nio.ch. >> SocketDispatcher.read0(Native Method) at sun.nio.ch.SocketDispatcher.read >> (SocketDispatcher.java:43) at sun.nio.ch.IOUtil.readIntoNativeBuffer( >> IOUtil.java:223) at sun.nio.ch.IOUtil.read(IOUtil.java:192) at sun.nio.ch >> .SocketChannelImpl.read(SocketChannelImpl.java:380) at io.netty.buffer. >> PooledUnsafeDirectByteBuf.setBytes(PooledUnsafeDirectByteBuf.java:288) >> at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:1054) >> at io.netty.channel.socket.nio.NioSocketChannel.doReadBytes(Nio >> SocketChannel.java:245) at io.netty.channel.nio.AbstractN >> ioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:106) at io. >> netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:527) >> at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized( >> NioEventLoop.java:484) at io.netty.channel.nio.NioEventLoop. >> processSelectedKeys(NioEventLoop.java:398) at io.netty.channel.nio. >> NioEventLoop.run(NioEventLoop.java:370) at io.netty.util.concurrent.Singl >> eThreadEventExecutor$5.run(SingleThreadEventExecutor.java:742) at io. >> netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(D >> efaultThreadFactory.java:145) at java.lang.Thread.run(Thread.java:745) >> >> >> >> Thanks for your help. >> >> -- >> You received this message because you are subscribed to a topic in the >> Google Groups "grpc.io" group. >> To unsubscribe from this topic, visit https://groups.google.com/d/ >> topic/grpc-io/xcKtw8EZEtI/unsubscribe. >> To unsubscribe from this group and all its topics, send an email to >> grpc-io+unsubscr...@googlegroups.com. >> To post to this group, send email to grpc-io@googlegroups.com. >> To view this discussion on the web visit https://groups.google.com/d/ >> msgid/grpc-io/43de1809-ea84-4c05-96cd-465dc430951b%40googlegroups.com >> <https://groups.google.com/d/msgid/grpc-io/43de1809-ea84-4c05-96cd-465dc430951b%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> > > -- > You received this message because you are subscribed to the Google Groups " > grpc.io" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to grpc-io+unsubscr...@googlegroups.com. > To post to this group, send email to grpc-io@googlegroups.com. > To view this discussion on the web visit https://groups.google.com/d/ > msgid/grpc-io/CAEYXUX6pu2h68LDX2agmv2Ccj_AF8FRoiwY6q3w0CXOs__bZvg% > 40mail.gmail.com > <https://groups.google.com/d/msgid/grpc-io/CAEYXUX6pu2h68LDX2agmv2Ccj_AF8FRoiwY6q3w0CXOs__bZvg%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "grpc.io" group. To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+unsubscr...@googlegroups.com. To post to this group, send email to grpc-io@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/CA%2B4M1oNeehECfKD7sUBF07AuKGoK6km%2Be3NfR6Y0USDw2UX67A%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.