You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "manzhizhen (GitHub)" <gi...@apache.org> on 2019/01/17 16:00:54 UTC

[GitHub] [incubator-dubbo] manzhizhen commented on issue #3262: "No provider available in XXXX" RpcException after server IO Busy

我大概明白你描述的问题的,在org.apache.dubbo.remoting.transport.AbstractClient的重连方法实际对isConnected()方法已经做了双重检查了,例如:

``
    @Override
    public void reconnect() throws RemotingException {
        if (!isConnected()) {
            connectLock.lock();
            try {
                if (!isConnected()) {
                    disconnect();
                    connect();
                }
            } finally {
                connectLock.unlock();
            }
        }
    }
``
	
而在其链接方法中,再次判断了isConnected(),因为根据你的描述,在其Netty4实现的子类NettyClient中,由于Netty4的关闭是异步的,可能会导致判断失误直接返回,那是不是可以去掉这个判断,达到预期的效果?
	
``
protected void connect() throws RemotingException {
        connectLock.lock();
        try {
			// 去掉这里的判断?
            if (isConnected()) {
                return;
            }
            initConnectStatusCheckCommand();
            doConnect();
            if (!isConnected()) {
                throw new RemotingException(this, "Failed connect to server " + getRemoteAddress() + " from " + getClass().getSimpleName() + " "
                        + NetUtils.getLocalHost() + " using dubbo version " + Version.getVersion()
                        + ", cause: Connect wait timeout: " + getConnectTimeout() + "ms.");
            } else {
                if (logger.isInfoEnabled()) {
                    logger.info("Successed connect to server " + getRemoteAddress() + " from " + getClass().getSimpleName() + " "
                            + NetUtils.getLocalHost() + " using dubbo version " + Version.getVersion()
                            + ", channel is " + this.getChannel());
                }
            }
            reconnect_count.set(0);
            reconnect_error_log_flag.set(false);
        } catch (RemotingException e) {
            throw e;
        } catch (Throwable e) {
            throw new RemotingException(this, "Failed connect to server " + getRemoteAddress() + " from " + getClass().getSimpleName() + " "
                    + NetUtils.getLocalHost() + " using dubbo version " + Version.getVersion()
                    + ", cause: " + e.getMessage(), e);
        } finally {
            connectLock.unlock();
        }
    }
``

[ Full content available at: https://github.com/apache/incubator-dubbo/issues/3262 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org