tryfix: reconnect to client on connection error
record-daemon / Build, check and test (push) Failing after 10s
record-daemon / Build, check and test (push) Failing after 10s
This commit is contained in:
@@ -206,16 +206,31 @@ impl Daemon {
|
||||
|
||||
match watcher.check()? {
|
||||
Some(true) => {
|
||||
// Client started
|
||||
// Client started - try to connect
|
||||
info!("League Client detected");
|
||||
self.state_machine
|
||||
.transition(StateTransition::ClientStarted);
|
||||
|
||||
|
||||
if let Some(creds) = watcher.credentials() {
|
||||
self.lqp_client.connect(creds.clone()).await?;
|
||||
self.lqp_client.start_event_listener().await?;
|
||||
// Start polling for live client events (kills, deaths, objectives)
|
||||
self.lqp_client.start_live_client_event_poller().await;
|
||||
match self.lqp_client.connect(creds.clone()).await {
|
||||
Ok(()) => {
|
||||
// Only transition to Monitoring after successful connection
|
||||
self.state_machine
|
||||
.transition(StateTransition::ClientStarted);
|
||||
|
||||
if let Err(e) = self.lqp_client.start_event_listener().await {
|
||||
warn!("Failed to start event listener: {}", e);
|
||||
// Still stay in Monitoring, will retry on next check
|
||||
} else {
|
||||
// Start polling for live client events (kills, deaths, objectives)
|
||||
self.lqp_client.start_live_client_event_poller().await;
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
warn!("Failed to connect to League Client: {}", e);
|
||||
// Don't transition to Monitoring - will retry on next check
|
||||
// The lockfile watcher will return None on next check since
|
||||
// credentials are already set, so we need to handle reconnection
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Some(false) => {
|
||||
@@ -225,7 +240,34 @@ impl Daemon {
|
||||
.transition(StateTransition::ClientStopped);
|
||||
self.lqp_client.disconnect().await;
|
||||
}
|
||||
None => {}
|
||||
None => {
|
||||
// No change in lockfile status
|
||||
// Check if we need to reconnect (lockfile exists but not connected)
|
||||
if watcher.credentials().is_some() && !self.lqp_client.is_connected().await {
|
||||
debug!("Lockfile exists but not connected, attempting reconnect...");
|
||||
if let Some(creds) = watcher.credentials() {
|
||||
match self.lqp_client.connect(creds.clone()).await {
|
||||
Ok(()) => {
|
||||
// Transition to Monitoring if not already
|
||||
if !self.state_machine.is_monitoring() {
|
||||
self.state_machine
|
||||
.transition(StateTransition::ClientStarted);
|
||||
}
|
||||
|
||||
if let Err(e) = self.lqp_client.start_event_listener().await {
|
||||
warn!("Failed to start event listener on reconnect: {}", e);
|
||||
} else {
|
||||
self.lqp_client.start_live_client_event_poller().await;
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
debug!("Reconnect attempt failed: {}", e);
|
||||
// Will retry on next check
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tokio::time::sleep(poll_interval).await;
|
||||
|
||||
Reference in New Issue
Block a user