Przeglądaj źródła

test: websocket

HeWang 6 miesięcy temu
rodzic
commit
29a749baac

+ 3 - 1
aarch64/pjibot_guide/common/config/c_websocket.go

@@ -57,6 +57,7 @@ func keepAlive() {
 		case <-ticker.C:
 			response, err := sendRequestAndAwaitResponse(WsConn)
 			if err != nil || response == nil {
+				c_log.GlobalLogger.Error("保持websocket连接活跃,此次请求未获取有效数据。", err)
 				continue
 			}
 			var responseMessage Response
@@ -104,8 +105,9 @@ func sendRequestAndAwaitResponse(ws *websocket.Conn) ([]byte, error) {
 	case response := <-responseChan:
 		c_log.GlobalLogger.Error("保持websocket连接活跃,等待心跳响应 - 成功。")
 		return response, nil
-	case <-time.After(30 * time.Second): // 设置超时时间
+	case <-time.After(60 * time.Second): // 设置超时时间
 		c_log.GlobalLogger.Error("保持websocket连接活跃,等待心跳响应 - 超时。")
+		close(responseChan)
 		return nil, fmt.Errorf("保持websocket连接活跃,等待心跳响应 - 超时。")
 	}
 }