Commit 7958ba9a authored by kezhenxu94's avatar kezhenxu94 Committed by 吴晟
Browse files

Fix bug: state not updated when GRPC auto reconnect to the same server (#3181)

parent d66f775f
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@
package org.apache.skywalking.apm.agent.core.remote;

import io.grpc.Channel;
import io.grpc.ConnectivityState;
import io.grpc.ManagedChannel;
import io.grpc.ManagedChannelBuilder;
import io.grpc.netty.NettyChannelBuilder;
@@ -73,6 +74,10 @@ public class GRPCChannel {
        return originChannel.isShutdown();
    }

    public boolean isConnected() {
        return originChannel.getState(false) == ConnectivityState.READY;
    }

    public static class Builder {
        private final String host;
        private final int port;
+7 −1
Original line number Diff line number Diff line
@@ -105,9 +105,15 @@ public class GRPCChannelManager implements BootService, Runnable {
                            .build();

                        notify(GRPCChannelStatus.CONNECTED);
                        reconnect = false;
                    } else if (managedChannel.isConnected()) {
                        // Reconnect to the same server is automatically done by GRPC,
                        // therefore we are responsible to check the connectivity and
                        // set the state and notify listeners
                        notify(GRPCChannelStatus.CONNECTED);
                        reconnect = false;
                    }

                    reconnect = false;
                    return;
                } catch (Throwable t) {
                    logger.error(t, "Create channel to {} fail.", server);