smallnest / rpcx

Best microservices framework in Go, like alibaba Dubbo, but with more features, Scale easily. Try it. Test it. If you feel it's better, use it! 𝐉𝐚𝐯𝐚有𝐝𝐮𝐛𝐛𝐨, 𝐆𝐨𝐥𝐚𝐧𝐠有𝐫𝐩𝐜𝐱! build for cloud!
https://rpcx.io
Other
8.11k stars 1.17k forks source link

rpcx出现connection timed out是预期内吗 #801

Closed XTeam-Wing closed 1 year ago

XTeam-Wing commented 1 year ago

多个节点公用一个server。容易出现以下错误

ERROR: rpcx: client protocol error: read tcp 172.28.0.2:50972->server_ip:20000: read: connection timed out
smallnest commented 1 year ago

需要看看你的客户端的配置

XTeam-Wing commented 1 year ago

大佬,这是我的调用demo,麻烦帮忙看一下下。

func CheckQueueExists(queueID string) (bool, error) {
    var reply model.TaskExistsResult
    xClient, err := rpcx.GetRpcx()
    if err != nil {
        logger.Errorf("getrpcx fail:%v", err)
        return false, err
    }
    err = xClient.Call(context.Background(), "CheckQueueExists", &queueID, &reply)
    if err != nil {
        return false, err
    }
    if reply.Exists {
        return true, nil
    }
    return false, errors.New("queue not exists")
}
func GetRpcx() (XClient client.XClient, err error) {
    d, err := client.NewPeer2PeerDiscovery("tcp@"+global.RpcxAddr, "")
    if err != nil {

        return XClient, err
    }

    option := client.DefaultOption
    option.Retries = 1000
    option.ConnectTimeout = 30 * time.Second

    XClient = client.NewXClient("Server", client.Failtry, client.RandomSelect, d, option)
    XClient.Auth(global.RpcxToken)
    return XClient, nil
}
smallnest commented 1 year ago

看起来就是网络问题,连接不到服务器。