moghtech/komodo · error · anyhow::Error
Failed to log in |
Error message
Failed to log in | {msg} What it means
connect_login_user_websocket performs a login handshake over the Komodo user websocket, expecting the server to reply with the exact text 'LOGGED_IN'. If any other text message arrives, the client closes the socket and returns this error containing the server's message — i.e. authentication over the websocket was rejected.
Solutions
- Read the {msg} part of the error — it contains the server's rejection reason
- Regenerate/verify the API key or JWT key used for authentication
- Confirm the target address points at the correct Komodo server with the right account
- Check server-side logs for the auth rejection to confirm the credential problem
Example fix
// before
let ws = komodo.connect_terminal(...).await?;
// after
let ws = komodo.connect_terminal(...).await.map_err(|e| {
if e.to_string().contains("Failed to log in") {
e.context("check KOMODO_API_KEY / jwt key and server address")
} else { e }
})?; Defensive patterns
Strategy: try-catch
Validate before calling
if api_key.is_empty() || jwt_key.is_empty() {
return Err(anyhow!("Komodo credentials missing before opening websocket"));
} Try / catch
match komodo.connect_terminal(terminal_target).await {
Ok(ws) => ws,
Err(e) if e.to_string().starts_with("Failed to log in") => {
eprintln!("auth rejected: {e}"); // refresh keys and retry
return Err(e);
}
Err(e) => return Err(e),
} Prevention
- Rotate and verify API keys before long-running sessions
- Validate the Komodo address env var points at the intended server
- Monitor server auth-rejection logs
When it happens
Trigger: Wrong or expired API key/JSON Web Key passed to connect_terminal or subscribe_to_updates; server rejecting credentials and sending a rejection message instead of 'LOGGED_IN'.
Common situations: Rotated or revoked Komodo API keys, misconfigured KOMODO_ADDRESS pointing at the wrong server, clock skew invalidating signed auth, or permission changes on the key.
Related errors
- Socket closed before login
- Must attach either swarm or server
- Cannot insert Service type configuration as additional…
- Connection closed
- Connection already closed
AI-assisted analysis of moghtech/komodo@780ac68b99 (2026-09-08).
Data as JSON: /api/errors/b0ff698a97f70d0e.
Report an issue: GitHub.
Appendix: source
Thrown at client/core/rs/src/ws/mod.rs:73
.await
.with_context(|| {
format!("failed to connect to Komodo websocket at {endpoint}")
})?;
ws.send(tungstenite::Message::Text(login_msg.into()))
.await
.context("Failed to send websocket login message")?;
loop {
match ws
.try_next()
.await
.context("Failed to receive websocket login response")?
{
Some(tungstenite::Message::Text(msg)) => {
if msg == "LOGGED_IN" {
return Ok(ws);
} else {
let _ = ws.close(None).await;
return Err(anyhow!("Failed to log in | {msg}"));
}
}
Some(tungstenite::Message::Close(_)) | None => {
let _ = ws.close(None).await;
return Err(anyhow!("Socket closed before login"));
}
// Keep looping on other message types
Some(_) => {}
};
}
}
}
View on GitHub (pinned to 780ac68b99)