safraeli commited on
Commit
0143c6f
·
verified ·
1 Parent(s): 0979cfc

Update backend/api/routes/health.py: circuit breaker, weather fix, TB health fix

Browse files
Files changed (1) hide show
  1. backend/api/routes/health.py +3 -3
backend/api/routes/health.py CHANGED
@@ -13,14 +13,14 @@ router = APIRouter()
13
 
14
 
15
  async def _check_thingsboard() -> bool:
16
- """Check ThingsBoard connectivity without blocking the event loop."""
17
  tb_host = os.environ.get("THINGSBOARD_HOST", "")
18
  if not tb_host:
19
  return False
20
  try:
21
  import urllib.request
22
- url = f"{tb_host.rstrip('/')}/api/noauth/health"
23
- # Run sync urllib in thread pool to avoid blocking event loop
24
  loop = asyncio.get_event_loop()
25
  resp = await loop.run_in_executor(
26
  None, lambda: urllib.request.urlopen(url, timeout=3)
 
13
 
14
 
15
  async def _check_thingsboard() -> bool:
16
+ """Check ThingsBoard connectivity by hitting the login page."""
17
  tb_host = os.environ.get("THINGSBOARD_HOST", "")
18
  if not tb_host:
19
  return False
20
  try:
21
  import urllib.request
22
+ # Use root URL — TB always responds to GET / with 200 (login page)
23
+ url = tb_host.rstrip("/") + "/"
24
  loop = asyncio.get_event_loop()
25
  resp = await loop.run_in_executor(
26
  None, lambda: urllib.request.urlopen(url, timeout=3)