mirror of
https://gitee.com/IrisVega/frp.git
synced 2024-11-01 22:31:29 +08:00
all: fix bug when reconnecting
This commit is contained in:
parent
6a0d6035cb
commit
d5913fc77b
@ -72,7 +72,10 @@ func msgReader(cli *client.ProxyClient, c *conn.Conn, msgSendChan chan interface
|
||||
log.Info("ProxyName [%s], try to reconnect to frps [%s:%d]...", cli.Name, client.ServerAddr, client.ServerPort)
|
||||
c, err = loginToServer(cli)
|
||||
if err == nil {
|
||||
close(msgSendChan)
|
||||
msgSendChan = make(chan interface{}, 1024)
|
||||
go heartbeatSender(c, msgSendChan)
|
||||
go msgSender(cli, c, msgSendChan)
|
||||
break
|
||||
}
|
||||
|
||||
@ -81,6 +84,7 @@ func msgReader(cli *client.ProxyClient, c *conn.Conn, msgSendChan chan interface
|
||||
}
|
||||
time.Sleep(delayTime * time.Second)
|
||||
}
|
||||
continue
|
||||
} else if err != nil {
|
||||
log.Warn("ProxyName [%s], read from frps error: %v", cli.Name, err)
|
||||
continue
|
||||
@ -117,7 +121,7 @@ func msgSender(cli *client.ProxyClient, c *conn.Conn, msgSendChan chan interface
|
||||
buf, _ := json.Marshal(msg)
|
||||
err := c.Write(string(buf) + "\n")
|
||||
if err != nil {
|
||||
log.Warn("ProxyName [%s], write to client error, proxy exit", cli.Name)
|
||||
log.Warn("ProxyName [%s], write to server error, proxy exit", cli.Name)
|
||||
c.Close()
|
||||
break
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ func msgReader(s *server.ProxyServer, c *conn.Conn, msgSendChan chan interface{}
|
||||
case consts.HeartbeatReq:
|
||||
log.Debug("ProxyName [%s], get heartbeat", s.Name)
|
||||
timer.Reset(time.Duration(server.HeartBeatTimeout) * time.Second)
|
||||
heartbeatRes := msg.ControlRes{
|
||||
heartbeatRes := &msg.ControlRes{
|
||||
Type: consts.HeartbeatRes,
|
||||
}
|
||||
msgSendChan <- heartbeatRes
|
||||
|
Loading…
Reference in New Issue
Block a user