微服务如何通过springgateway调用python服务,现在通过服务名调用一直出现
{
"msg": "Failed to handle request [GET http://10.24.0.163:8081/zjl-knowledge-service/api/v1/health]: 503 SERVICE_UNAVAILABLE \"Unable to find instance for zjl-knowledge-service\"",
"code": 503,
"data": null
}
直接调用接口返回
{
"msg": "所有系统组件运行正常",
"code": 200,
"data": {
"overall_status": "healthy",
"timestamp": "2024-01-01T00:00:00Z",
"version": "0.1.0",
"environment": "production",
"checks": {
"application": {
"status": "healthy",
"app_name": "ZJL知识库系统",
"version": "0.1.0",
"uptime": "正常运行",
"config_loaded": true,
"dependencies_loaded": true
},
"mysql": {
"status": "healthy",
"connection_pool": "active",
"response_time_ms": 15,
"active_connections": 5,
"max_connections": 100
},
"milvus": {
"status": "healthy",
"connection": "active",
"response_time_ms": 25,
"collections_count": 3,
"index_status": "built"
},
"redis": {
"status": "healthy",
"connection": "active",
"memory_usage": "45MB",
"cache_hit_rate": 0.85,
"response_time_ms": 5
},
"embedding_service": {
"status": "healthy",
"provider": "azure_openai",
"model": "text-embedding-3-large",
"vector_dimension": 3072,
"test_response_time_ms": 120,
"api_quota_remaining": "充足"
},
"azure_openai": {
"status": "healthy",
"endpoint": "已连接",
"api_version": "2023-05-15",
"deployment": "text-embedding-3-large",
"quota_usage": "正常",
"response_time_ms": 180
},
"minio_storage": {
"status": "healthy",
"connection": "active",
"bucket_accessible": true,
"storage_used": "1.2GB",
"storage_available": "98.8GB",
"response_time_ms": 35
},
"local_storage": {
"status": "healthy",
"disk_usage": "65%",
"available_space": "50GB",
"temp_directory": "可写",
"log_directory": "可写"
}
},
"severity": "low",
"message": "所有系统组件运行正常",
"performance_summary": {
"total_checks": 8,
"healthy_services": 8,
"warning_services": 0,
"critical_services": 0,
"overall_response_time_ms": 85,
"system_load": "normal"
},
"recommendations": [
"✅ 系统运行良好,建议保持定期监控"
],
"support_info": {
"documentation": "https://docs.example.com/health-check",
"support_email": "support@example.com",
"emergency_contact": "紧急联系方式",
"monitoring_dashboard": "监控面板地址"
}
}
}
你用一个原生的springcloud gateway工程(不用bladex自带,新建个空白工程)去注册到nacos然后路由你的python服务,看看能不能成功,如果原版的可以,bladex不行,请把demo发我们邮箱 bladejava@qq.com ,我们安排去排查。
如果原版的也不行,那就是spring本身的配置问题,需要去找到准确的配置看看如何进行路由。
刚刚建了一个demo测试 原生的springcloud gateway工程是可以调用的 我现在将demo发送你们邮箱
原生调用
bladex网关调用
往上看,有demo配置
好的 现在可以了 但是还有一个问题 调用 http://10.24.0.163:8081/zjl-knowledge-service/api/v1/health 实际调用是 http://serverIp:serverProt/v1/health /api被重写掉了
已经解决了,发现好像获取服务时只认 preserved.register.source=SPRING_CLOUD
的服务,metadata没有这个的话会过滤掉,服务注册加上这个就能正常调用
扫一扫访问 Blade技术社区 移动端