diff --git a/src/modules/ws/controller/ws.go b/src/modules/ws/controller/ws.go index b9051c40..50fd01fa 100644 --- a/src/modules/ws/controller/ws.go +++ b/src/modules/ws/controller/ws.go @@ -196,11 +196,11 @@ func (s *WSController) SSH(c *gin.Context) { wsClient.MsgChan <- msgByte // 退出ssh登录 - if strings.LastIndex(outputStr, "logout\r\n") != -1 { - time.Sleep(1 * time.Second) - s.wsService.CloseClient(wsClient.ID) - return - } + // if strings.LastIndex(outputStr, "logout\r\n") != -1 { + // time.Sleep(1 * time.Second) + // s.wsService.CloseClient(wsClient.ID) + // return + // } } } }() @@ -283,11 +283,11 @@ func (s *WSController) Telnet(c *gin.Context) { wsClient.MsgChan <- msgByte // 退出telnet登录 - if strings.LastIndex(outputStr, "logout\r\n") != -1 { - time.Sleep(1 * time.Second) - s.wsService.CloseClient(wsClient.ID) - return - } + // if strings.LastIndex(outputStr, "logout\r\n") != -1 { + // time.Sleep(1 * time.Second) + // s.wsService.CloseClient(wsClient.ID) + // return + // } } } }() diff --git a/src/modules/ws/service/ws_receive.impl.go b/src/modules/ws/service/ws_receive.impl.go index 00648e25..3df49304 100644 --- a/src/modules/ws/service/ws_receive.impl.go +++ b/src/modules/ws/service/ws_receive.impl.go @@ -3,6 +3,7 @@ package service import ( "encoding/json" "fmt" + "io" "time" "be.ems/src/framework/logger" @@ -83,6 +84,11 @@ func (s *WSReceiveImpl) AsyncReceive(client *model.WSClient, reqMsg model.WSRequ logger.Warnf("ws AsyncReceive UID %s err: %s", client.BindUid, err.Error()) msgByte, _ := json.Marshal(result.ErrMsg(err.Error())) client.MsgChan <- msgByte + if err == io.EOF { + // 等待1s后关闭连接 + time.Sleep(1 * time.Second) + client.StopChan <- struct{}{} + } return } if len(resByte) > 0 {