On Mon, Aug 23, 2021 at 7:57 AM Sidhartha Thota <[email protected]>
wrote:

> Hi Sanjay,
>
> Yes. my requirement is that I need my server to know about a client
> connection init/termination status. Do we have any other way to accomplish
> this? Please note, I need client address when it disconnects.
>

Use TRANSPORT_ATTR_REMOTE_ADDR
<https://github.com/grpc/grpc-java/blob/master/api/src/main/java/io/grpc/Grpc.java#L40>


> I will try once again if transportReady() is called after RPC call is
> started.
>

I am confident that if transportReady() works, then transportTerminated
will work too.


>
> On Fri, Aug 20, 2021 at 2:30 PM '[email protected]' via grpc.io <
> [email protected]> wrote:
>
>> Do you see the callback `transportReady()` being called? Pls make sure
>> `transportReady()` is called. Because of lazy init the connection may not
>> even have been created unless you sent RPCs
>>
>> Also what's your use case that you need to know about a client connection
>> init/termination status?
>>
>> On Thursday, August 19, 2021 at 12:57:26 AM UTC-7 [email protected]
>> wrote:
>>
>>> Hi,
>>>
>>> I am looking for a java GRPC server to know if any client (clients are
>>> c++ if it matters) connection disconnected abruptly due to network issue. I
>>> learnt from google search that GRPC java have serviceTransportFilter(
>>> https://grpc.github.io/grpc-java/javadoc/io/grpc/ServerTransportFilter.html)
>>> which can be added to ServerBuilder and the functions `transportReady`
>>> and `transportTerminated` are called when client is connected and
>>> disconnected. I added transport filter to my serverbuilder and killed by
>>> client program using `kill -9` but I don't see these method getting
>>> triggered. Am i missing anything? or my understanding about transport
>>> filter is wrong?
>>>
>>> My serverTransportFilter implementation
>>> public class GRPCServerTransportFilter extends ServerTransportFilter {
>>> private static final Logger LOG = LoggerFactory.getLogger(
>>> GRPCServerTransportFilter.class);
>>>
>>> @Override
>>> public Attributes transportReady(final Attributes transportAttrs) {
>>> LOG.info("Client connected {}", transportAttrs.toString());
>>> return transportAttrs;
>>> }
>>>
>>> @Override
>>> public void transportTerminated(final Attributes transportAttrs) {
>>> LOG.info("Client disconnected {}", transportAttrs.toString());
>>> }
>>> }
>>>
>>>
>>> NettyServerBuilder build code
>>> io.grpc.Server server server = NettyServerBuilder.forPort(port)
>>> .permitKeepAliveWithoutCalls(true)
>>> .permitKeepAliveTime(keepAliveTimeOut, TimeUnit.SECONDS)
>>> .addService(new GeyserListenerGRPCService(this::executeHandler,
>>> this::onError, this::onCompleted))
>>> .addTransportFilter(new GRPCServerTransportFilter())
>>> .build();
>>> server.start();
>>>
>>> --
>>> Thanks,
>>> Sid.
>>>
>> --
>> 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 [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/grpc-io/a741f7c7-1c8c-4925-8a37-fdcc48c4ef4cn%40googlegroups.com
>> <https://groups.google.com/d/msgid/grpc-io/a741f7c7-1c8c-4925-8a37-fdcc48c4ef4cn%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>
>
> --
> Thanks,
> Sidhartha Thota.
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/CA%2BPad6jQoqLAsKKKrtdWE%3DbvAv3j5%2BLCwq_pz1vYhwUYQA-BoQ%40mail.gmail.com.

Reply via email to