|
@@ -28,9 +28,10 @@ func NewRPCClient() (*RPCClient, error) {
|
|
func rpcCallWithReconnect(client *rpc.Client, addr string, serverMethod string, args interface{}, reply interface{}) error {
|
|
func rpcCallWithReconnect(client *rpc.Client, addr string, serverMethod string, args interface{}, reply interface{}) error {
|
|
err := client.Call(serverMethod, args, reply)
|
|
err := client.Call(serverMethod, args, reply)
|
|
if err == rpc.ErrShutdown {
|
|
if err == rpc.ErrShutdown {
|
|
- Log.Warn("rpc connection shut down, trying to reconnect...")
|
|
|
|
|
|
+ Log.Warnf("rpc %s connection shut down, trying to reconnect...", addr)
|
|
client, err = rpc.Dial("tcp", addr)
|
|
client, err = rpc.Dial("tcp", addr)
|
|
if err != nil {
|
|
if err != nil {
|
|
|
|
+ Log.Debugf("重新连接%s失败:%s", addr, err.Error())
|
|
return err
|
|
return err
|
|
}
|
|
}
|
|
return client.Call(serverMethod, args, reply)
|
|
return client.Call(serverMethod, args, reply)
|
|
@@ -60,7 +61,6 @@ func (client *RPCClient) Call(severName string, serverMethod string, args interf
|
|
}
|
|
}
|
|
err = rpcCallWithReconnect(client.clients[mapkey], addr, serverMethod, args, reply)
|
|
err = rpcCallWithReconnect(client.clients[mapkey], addr, serverMethod, args, reply)
|
|
if err != nil {
|
|
if err != nil {
|
|
- Log.WithField("method", serverMethod).Warnf("RpcCallWithReconnect error : %s", err)
|
|
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
|
|
|