On the Node side, that is surfaced as a non-OK status. You can handle those by listening to the 'error' event on the stream object that is created when you start the call.
On Tue, Nov 8, 2016 at 11:35 AM Harshal Jethwa <harshal...@gmail.com> wrote: > I am using grpc to communicate between a Java server and node client. When > either of them die/crash the other dies to. > > Here is the exception thrown on Java server when node client dies - > > Nov 08, 2016 11:28:03 AM io.grpc.netty.NettyServerHandler onConnectionError > WARNING: Connection Error > java.io.IOException: An existing connection was forcibly closed by the remote > host > 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:1100) > at > io.netty.channel.socket.nio.NioSocketChannel.doReadBytes(NioSocketChannel.java:349) > at > io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:112) > at > io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:571) > at > io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:512) > at > io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:426) > at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:398) > at > io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:877) > at > io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:144) > at java.lang.Thread.run(Thread.java:745) > > Here is the exception thrown on node when java dies: > > events.js:141 > throw er; // Unhandled 'error' event > ^ > Error: {"created":"@1478623914.082000000","description":"An existing > connection was forcibly closed by the remote > host.\r\n","file":"..\src\core\lib\iomgr\tcp_windows.c","file_line":171,"grpc_status":14} > at ClientReadableStream._emitStatusIfDone ( > C:\HarshalDev\Live_TDFX\TDSL0007-TDFXPlatfo > rmsDesignandBuild\tdfxlive\node_modules\grpc\src\node\src\client.js:189:19) > at ClientReadableStream._receiveStatus (C:\ > HarshalDev\Live_TDFX\TDSL0007-TDFXPlatformsDesignandBuild\tdfxlive\node_modules\grpc\src\node\src\client.js:169:8) > at > C:\HarshalDev\Live_TDFX\TDSL0007-TDFXPlatformsDesignandBuild\tdfxlive\node_modules\grpc\src\node\src\client.js:577:14 > [nodemon] app crashed - waiting for file changes before starting... > > QUESTION - How do I handle those exceptions? > > I tried without any success adding try/catch and adding a uncaught > exception handlers for threads. > > Java code to initialize - > > ServerBuilder<?> serverBuilder = ServerBuilder.forPort(getPort()); > server = serverBuilder > .addService(createBwayStreamingService()) > .addService(ServerInterceptors.intercept(createBwayOrderService(), > authServerInterceptor)) > .addService(createBwayInstrumentService()) > .addService(createBwaySettlementService()) > .addService(createBwayDateTimeService()) > .addService(ServerInterceptors.intercept(createBwayConfService(), > authServerInterceptor)) > .addService(ServerInterceptors.intercept(createBwayTradeService(), > authServerInterceptor)) > .addService(ServerInterceptors.intercept(createBwayAuthService(), > authServerInterceptor)) > .build(); > Preconditions.checkNotNull(server); > server.start(); > System.out.println("Server started, listening on " + getPort()); > Runtime.getRuntime().addShutdownHook(new Thread() { > @Override > public void run() { > System.out.println("Shutting down gRPC server"); > TocGateway.this.stop(); > System.out.println("Server shut down"); > } > }); > server.awaitTermination(); > > Node client handler (one of the services, all other services use the same > pattern) - > > let protoDescriptorStreaming = grpc.load((process.env.FX_LIVE_PROTO_DIR || > '../tocGateway/src/main/proto') + '/streaming.proto'); > let streamingService = new > protoDescriptorStreaming.tds.fxlive.bway.BwayStreamService(process.env.TOC_GATEWAY_ADDRESS > || 'localhost:8087', grpc.credentials.createInsecure()); > > -- > 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. > Visit this group at https://groups.google.com/group/grpc-io. > To view this discussion on the web visit > https://groups.google.com/d/msgid/grpc-io/4082269e-669d-400e-b124-f17f5ebc434c%40googlegroups.com > <https://groups.google.com/d/msgid/grpc-io/4082269e-669d-400e-b124-f17f5ebc434c%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. Visit this group at https://groups.google.com/group/grpc-io. To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/CAPK2-4cym-7gGoPNtmCwK6Exe0y7uhdKaNy93Fpi%3DJ8XTCW-rw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
smime.p7s
Description: S/MIME Cryptographic Signature