henrygd/beszel · error
timeout creating session
Error message
timeout creating session
What it means
createSessionWithTimeout gives up when the SSH session cannot be created before the request context is cancelled (ctx.Done() fires). Request therefore fails because the underlying SSH connection could not produce a session in time.
Source
Thrown at internal/hub/transport/ssh.go:187
sessionChan := make(chan *ssh.Session, 1)
errChan := make(chan error, 1)
go func() {
session, err := t.client.NewSession()
if err != nil {
errChan <- err
} else {
sessionChan <- session
}
}()
select {
case session := <-sessionChan:
return session, nil
case err := <-errChan:
return nil, err
case <-ctx.Done():
return nil, errors.New("timeout creating session")
}
}
// extractAgentVersion extracts the beszel version from SSH server version string.
func extractAgentVersion(versionString string) (semver.Version, error) {
_, after, _ := strings.Cut(versionString, "_")
return semver.Parse(after)
}
// RequestWithRetry sends a request with automatic retry on connection failures.
func (t *SSHTransport) RequestWithRetry(ctx context.Context, action common.WebSocketAction, req any, dest any, retries int) error {
var lastErr error
for attempt := 0; attempt <= retries; attempt++ {
err := t.Request(ctx, action, req, dest)
if err == nil {
return nil
}
lastErr = errView on GitHub (pinned to b38fb7dafa)
Solutions
- Increase the SSH request timeout / context deadline
- Verify network connectivity to the host (ping, nc on the SSH port)
- Check SSH server responsiveness and MaxStartups throttling on the host
- Ensure DNS resolution is fast; use IP or faster resolver if needed
- Retry; transient network stalls often resolve
Example fix
// before ctx, cancel := context.WithTimeout(context.Background(), 4*time.Second) // after ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second) // slow links
Defensive patterns
Strategy: retry
Validate before calling
conn, err := net.DialTimeout("tcp", host+":22", 5*time.Second)
if err != nil { return fmt.Errorf("host unreachable: %w", err) } Try / catch
data, err := client.RequestWithRetry(common.GetData, dest)
if err != nil {
if strings.Contains(err.Error(), "timeout creating session") {
// backoff and retry, or mark system as unreachable
}
return err
} Prevention
- Set realistic SSH timeouts for your network latency
- Alert on hosts that repeatedly time out
- Verify firewalls permit the SSH port; check sshd MaxStartups
When it happens
Trigger: sessionChan produced no session and errChan no error before ctx was done — slow SSH handshake/authentication, network stall, or a very short request timeout.
Common situations: Remote host unreachable or dropping packets (silent firewall drop); slow DNS; server slow to accept auth; default timeout too low for high-latency links (satellite/VPN); hub under heavy load.
Understand the failure class
- Timeouts: ETIMEDOUT, deadlines, and hung requests — what actually expires when a request times out.
Related errors
- timeout
- ${resp.Error}
- no key provided: must set -key flag, KEY env var, or KEY_FIL
- failed to read key file: %w
- temperature collection timed out
AI-assisted analysis of henrygd/beszel@b38fb7dafa (2026-08-31).
Data as JSON: /api/errors/816f62886b8fb886.
Report an issue: GitHub.