### JAVA Code

```
            channel = 
ManagedChannelBuilder.forTarget(param.getTarget()).build();
            long channelStart = System.currentTimeMillis();
            asyncStub = ASRRouteGrpc.newStub(channel);
            asrResponseStreamObserver = new 
ASRResponseStreamObserver(speechTranscriberListener);
            requestObserver = asyncStub.route(asrResponseStreamObserver);
            RouteRequest requestConf = newRequestHead(param);
            traceId = requestConf.getAsrConfig().getTraceId();
            ConnectivityState currentChannelState = channel.getState(true);
            while (currentChannelState != ConnectivityState.READY) {
                CountDownLatch latchUntilChannelReady = new 
CountDownLatch(1);
                channel.notifyWhenStateChanged(currentChannelState, 
latchUntilChannelReady::countDown);
                latchUntilChannelReady.await();
                currentChannelState = channel.getState(true);
                if (currentChannelState == ConnectivityState.CONNECTING) {
                    long channelConnecting = System.currentTimeMillis();
                    LOGGER.info("The transition from idle state to 
connecting takes: {} ms", channelConnecting - channelStart);
                }
            }
            long channelReady = System.currentTimeMillis();
            if (LOGGER.isInfoEnabled()) {
                LOGGER.info("Trace id: {}, channel start time: {}, channel 
ready time: {}, creating channel takes: {} ms", traceId, channelStart, 
channelReady,
                        channelReady - channelStart);
            }
```
### LOGGER

```
2023-08-22 14:12:34,816 INFO  client.ASRClient - The transition from idle 
state to connecting takes: 1009 ms
2023-08-22 14:12:34,841 INFO  client.ASRClient - Trace id: 
6afd2c67-e8c5-4cea-bd5c-4b82591a52aa, channel start time: 1692684753807, 
channel ready time: 1692684754841, creating channel takes: 1034 ms
```
### Description
#### code logic
1. first create channel
2. mark a time stamp(channelStart) after the channel is created
3. get the state of channel ,the state is IDEL
4. when the state of channel changes from IDEL to CONNECTING,mark a time 
stamp(channelConnecting)
5. when the state of channel changes from CONNECTING to READY, mark a time 
stamp(channelReady)

#### Log info 
1. It takes 1009ms for channel from IDLE state to CONNECTING state.
2. It takes 25ms for channel from CONNECTIONG state to READY state.
### What's i supposed
1. Does it take too long for a channel to change from IDLE to CONNECTING?
2. I want to reduce the time it takes for a channel to go from IDLE to 
CONNECTING.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/a46f48b1-a433-4ec9-89d9-c82ffb4b0063n%40googlegroups.com.

Reply via email to