fix: increase device connect timeout from 30s to 60s
KL520 USB Boot flow needs ~40s: retry connect (3x2s) + firmware load + 5s reboot wait + reconnect retry (3x3s). 30s was too tight. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
9950bf7232
commit
49bdef68c7
@ -71,9 +71,9 @@ func (h *DeviceHandler) GetDevice(c *gin.Context) {
|
||||
func (h *DeviceHandler) ConnectDevice(c *gin.Context) {
|
||||
id := c.Param("id")
|
||||
|
||||
// Run connect with a 30-second timeout to avoid blocking the HTTP
|
||||
// request for over a minute when the SDK connect hangs.
|
||||
ctx, cancel := context.WithTimeout(c.Request.Context(), 30*time.Second)
|
||||
// KL520 USB Boot flow can take ~40s: retry connect (3x2s) + firmware
|
||||
// load + 5s reboot wait + reconnect retry (3x3s). Use 60s timeout.
|
||||
ctx, cancel := context.WithTimeout(c.Request.Context(), 60*time.Second)
|
||||
defer cancel()
|
||||
|
||||
errCh := make(chan error, 1)
|
||||
@ -94,7 +94,7 @@ func (h *DeviceHandler) ConnectDevice(c *gin.Context) {
|
||||
case <-ctx.Done():
|
||||
c.JSON(504, gin.H{
|
||||
"success": false,
|
||||
"error": gin.H{"code": "CONNECT_TIMEOUT", "message": fmt.Sprintf("device connect timed out after 30s for %s", id)},
|
||||
"error": gin.H{"code": "CONNECT_TIMEOUT", "message": fmt.Sprintf("device connect timed out after 60s for %s", id)},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user