Command exited with code 0. Command output: 2499- if not ws.active or not ws.forward_to or ws.active_mode not in ("firebase", "fcm") or not ws.device_id: 2500- await asyncio.sleep(poll_interval) 2501- continue 2502- 2503- if not self.http: 2504- await asyncio.sleep(poll_interval) 2505- continue 2506- 2507- fb = normalize_firebase_url(ws.firebase_url) 2508- if not fb: 2509: log(f"[fb poll {user_id}] Invalid or empty Firebase URL ({ws.firebase_url}). Auto-pausing.") 2510- ws.active = False 2511- self.save_workspace(ws) 2512- await self.send(user_id, fmt_msg("Firebase Paused", "⚠️ **Firebase URL is invalid.** Setup paused automatically to prevent server errors.", error=True)) 2513- break 2514- 2515- url = f"{fb}/messages/{ws.device_id}.json" 2516- if ws.firebase_auth: 2517- url += f"?auth={ws.firebase_auth}" 2518- cutoff_ts = ws.last_processed_ts 2519- -- 2526- except Exception: 2527- seed_data = None 2528- if isinstance(seed_data, dict): 2529- cutoff_ts = self._latest_remote_ts(seed_data) 2530- if cutoff_ts: 2531- ws.last_processed_ts = max(0, cutoff_ts - 5000) 2532- self.save_workspace(ws) 2533- elif seed.status in (401, 403, 404, 423): 2534- consecutive_errors += 1 2535- if consecutive_errors >= 6: 2536: log(f"[fb poll {user_id}] Seed HTTP {seed.status} repeated. Auto-pausing.") 2537- ws.active = False 2538- self.save_workspace(ws) 2539- await self.send(user_id, fmt_msg("Firebase Paused", f"⚠️ Database returned HTTP {seed.status}. Paused automatically.", error=True)) 2540- break 2541- await asyncio.sleep(20) 2542- continue 2543- await asyncio.sleep(poll_interval) 2544- continue 2545- 2546- async with self.http.get(url, timeout=fb_timeout) as r: 2547- if r.status != 200: 2548- consecutive_errors += 1 2549- if r.status in (401, 403, 404, 423): 2550- if consecutive_errors >= 6: 2551: log(f"[fb poll {user_id}] Persistent HTTP {r.status} error ({consecutive_errors} times). Auto-pausing.") 2552- ws.active = False 2553- self.save_workspace(ws) 2554- await self.send(user_id, fmt_msg("Firebase Paused", f"⚠️ Database returned HTTP {r.status} repeatedly. Paused automatically.", error=True)) 2555- break 2556- await asyncio.sleep(20) 2557- else: 2558- await asyncio.sleep(poll_interval) 2559- continue 2560- 2561- try: -- 2602- 2603- await asyncio.sleep(poll_interval) 2604- 2605- except asyncio.CancelledError: 2606- break 2607- except Exception as exc: 2608- consecutive_errors += 1 2609- err_text = str(exc).lower() 2610- if "name or service not known" in err_text or "cannot connect to host" in err_text or "nodename" in err_text: 2611- if consecutive_errors >= 5: 2612: log(f"[fb poll {user_id}] Persistent host failure. Auto-pausing.") 2613- ws.active = False 2614- self.save_workspace(ws) 2615- await self.send(user_id, fmt_msg("Firebase Paused", "⚠️ Host domain could not be reached repeatedly. Paused automatically.", error=True)) 2616- break 2617: log(f"[fb poll {user_id}] Host connection/lookup failed: {exc}. Backing off 30s...") 2618- await asyncio.sleep(30) 2619- else: 2620- err_msg = str(exc) or type(exc).__name__ 2621: log(f"[fb poll {user_id}] {err_msg}") 2622- await asyncio.sleep(max(2.0, poll_interval * 2)) 2623- 2624- def _latest_remote_ts(self, data: dict[str, Any]) -> int: 2625- latest_ts = 0 2626- for key in data.keys(): 2627- try: 2628- latest_ts = max(latest_ts, int(key)) 2629- except Exception: 2630- continue 2631- return latest_ts