From 6c91a15a72e513a036c01e9aed81ff5448c4f9cf Mon Sep 17 00:00:00 2001 From: happybell80 Date: Sat, 27 Sep 2025 11:54:23 +0900 Subject: [PATCH] =?UTF-8?q?docs:=20Gateway=20Stats=20API=20=EC=8A=AC?= =?UTF-8?q?=EB=9E=98=EC=8B=9C=20=EC=A4=91=EB=B3=B5=20=EB=AC=B8=EC=A0=9C=20?= =?UTF-8?q?=ED=95=B4=EA=B2=B0=20=EB=82=B4=EC=9A=A9=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 문제: URL 조합 시 슬래시 3개 발생 (///api/stats/rb8001) - 해결: settings.get_monitor_stats_url() 메서드로 정규화 - 결과: 슬래시 정규화 완료, 200 OK 확인 - 상태: 미해결 → 해결 완료 (efca09f) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- ...6_happybell80_gateway_redis_integration.md | 34 +++++++++++++------ 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/troubleshooting/250926_happybell80_gateway_redis_integration.md b/troubleshooting/250926_happybell80_gateway_redis_integration.md index 4e9c28b..cc54ddb 100644 --- a/troubleshooting/250926_happybell80_gateway_redis_integration.md +++ b/troubleshooting/250926_happybell80_gateway_redis_integration.md @@ -61,15 +61,29 @@ docker inspect robeing-gateway auth-redis | grep -A2 "Networks" --- -## 6. 현재 상태 (2025-09-27) +## 6. Stats API 슬래시 중복 문제 해결 (2025-09-27) -### Stats API 404 반복 발생 +### 문제 - **증상**: `http://192.168.219.52:9024///api/stats/rb8001` 404 응답 (1분마다) -- **URL 형식**: 슬래시 3개 (`///`) 발생 중 -- **현재 설정**: - - `MONITOR_URL="http://192.168.219.52:9024"` - - `MONITOR_STATUS_URI="/api/stats"` -- **코드**: `main.py:290` - `f"{env_setting.MONITOR_URL}/{env_setting.MONITOR_STATUS_URI}/{robeing_id}"` -- **실제 동작**: robeing-monitor API는 정상 (`curl http://localhost:9024/api/stats/rb8001` 성공) -- **폴백**: 404 시 기본값 반환 중 -- **상태**: 미해결 \ No newline at end of file +- **원인**: URL 조합 시 슬래시 중복 (`MONITOR_URL` 끝 + `MONITOR_STATUS_URI` 앞 + f-string 내부) +- **기존 코드**: `main.py:290` - `f"{env_setting.MONITOR_URL}/{env_setting.MONITOR_STATUS_URI}/{robeing_id}"` + +### 해결 방법 +**settings.py에 URL 생성 메서드 추가**: +```python +def get_monitor_stats_url(self, robeing_id: str) -> str: + monitor_url = str(self.MONITOR_URL).rstrip('/') if self.MONITOR_URL else "" + status_uri = self.MONITOR_STATUS_URI.strip('/') if self.MONITOR_STATUS_URI else "" + return f"{monitor_url}/{status_uri}/{robeing_id}" +``` + +**main.py 수정**: +```python +target_url = env_setting.get_monitor_stats_url(robeing_id) +``` + +### 결과 +- ✅ 슬래시 정규화: `///` → `/` +- ✅ URL 생성 로직 중앙화 +- ✅ 환경변수 설정 오류 방지 +- **상태**: 해결 완료 (efca09f) \ No newline at end of file