根据 Eureka API 文档注册非 Java 应用程序 - 问题
Registration of non-Java App following Eureka API Documentation - Issue
我的 localhost:8090 中有 Eureka 运行。我在那个 Eureka 中注册了独立的 Java 应用程序,我可以使用我的 Zuul URL 访问它们,它也注册到那个 Eureka。
现在我有另一个 Python(3.7.3)+Flask 应用程序,我试图在同一个 Eureka 中注册并通过同一个 Zuul URL 访问它。
我的 Python 应用程序使用这些命令通过 DOCKERFILE 在本地运行良好 -
EXPOSE 8443
CMD ["python", "PythonFlaskSample.py"]
这将打开一个网页 URL -
http://localhost:8443/home
然后为了在 Eureka 中注册这个 App,我按照这个文档 -
https://github.com/Netflix/eureka/wiki/Eureka-REST-operations
和
https://automationrhapsody.com/json-format-register-service-eureka/
也尝试通过 REST 客户端使用 POST URL 作为 -
http://localhost:8090/eureka/v2/apps/PythonFlaskApp
内容类型:application/json
{
"instance": {
"hostName": "localhost",
"app": "PythonFlaskSample",
"vipAddress": "localhost",
"secureVipAddress": "localhost",
"ipAddr": "<Which IP>????",
"status": "STARTING",
"port": {"$": "8090", "@enabled": "true"},
"securePort": {"$": "8443", "@enabled": "true"},
"healthCheckUrl": "http://localhost:8090/health",
"statusPageUrl": "http://localhost:8090/info",
"homePageUrl": "http://localhost:8090",
"dataCenterInfo": {
"@class": "com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo",
"name": "MyOwn"
},
}
}
但是它抛出一个 405 并且没有其他线索来说明 Restlet 客户端或 Postman 中发生了什么。
当我尝试将 JSON 有效负载放入 python 文件并从那里使用 POST 时,
request_body = {
"instance": {
"hostName": "localhost",
"app": "PythonFlaskSample",
"vipAddress": "localhost",
"secureVipAddress": "localhost",
"ipAddr": "<Which IP>????",
"status": "STARTING",
"port": {"$": "8090", "@enabled": "true"},
"securePort": {"$": "8443", "@enabled": "true"},
"healthCheckUrl": "http://localhost:8090/health",
"statusPageUrl": "http://localhost:8090/info",
"homePageUrl": "http://localhost:8090",
"dataCenterInfo": {
"@class": "com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo",
"name": "MyOwn"
},
}
}
data=json.dumps(request_body)
url="http://localhost:8090"
response = requests.post(url,data=json.dumps(request_body), headers = {'Content-type':'application/json'}).json()
print(response)
显示以下错误-
docker run -p 8443:8443 dockerpython {'timestamp': 1555717403333,
'status': 405, 'error': 'Method Not Allowed', 'exception':
'org.springframework.web.HttpRequestMethodNotSupportedException',
'message': "Request method 'POST' not supported", 'path': '/'}
我错过了什么?
这是 Eureka API 文档中的一个错误 - https://github.com/Netflix/eureka/wiki/Eureka-REST-operations. Once I tried same REST URLs without "/v2" , everything worked fine.enter image description here
我的 localhost:8090 中有 Eureka 运行。我在那个 Eureka 中注册了独立的 Java 应用程序,我可以使用我的 Zuul URL 访问它们,它也注册到那个 Eureka。
现在我有另一个 Python(3.7.3)+Flask 应用程序,我试图在同一个 Eureka 中注册并通过同一个 Zuul URL 访问它。 我的 Python 应用程序使用这些命令通过 DOCKERFILE 在本地运行良好 -
EXPOSE 8443
CMD ["python", "PythonFlaskSample.py"]
这将打开一个网页 URL - http://localhost:8443/home
然后为了在 Eureka 中注册这个 App,我按照这个文档 -
https://github.com/Netflix/eureka/wiki/Eureka-REST-operations 和 https://automationrhapsody.com/json-format-register-service-eureka/
也尝试通过 REST 客户端使用 POST URL 作为 - http://localhost:8090/eureka/v2/apps/PythonFlaskApp 内容类型:application/json
{
"instance": {
"hostName": "localhost",
"app": "PythonFlaskSample",
"vipAddress": "localhost",
"secureVipAddress": "localhost",
"ipAddr": "<Which IP>????",
"status": "STARTING",
"port": {"$": "8090", "@enabled": "true"},
"securePort": {"$": "8443", "@enabled": "true"},
"healthCheckUrl": "http://localhost:8090/health",
"statusPageUrl": "http://localhost:8090/info",
"homePageUrl": "http://localhost:8090",
"dataCenterInfo": {
"@class": "com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo",
"name": "MyOwn"
},
}
}
但是它抛出一个 405 并且没有其他线索来说明 Restlet 客户端或 Postman 中发生了什么。
当我尝试将 JSON 有效负载放入 python 文件并从那里使用 POST 时,
request_body = {
"instance": {
"hostName": "localhost",
"app": "PythonFlaskSample",
"vipAddress": "localhost",
"secureVipAddress": "localhost",
"ipAddr": "<Which IP>????",
"status": "STARTING",
"port": {"$": "8090", "@enabled": "true"},
"securePort": {"$": "8443", "@enabled": "true"},
"healthCheckUrl": "http://localhost:8090/health",
"statusPageUrl": "http://localhost:8090/info",
"homePageUrl": "http://localhost:8090",
"dataCenterInfo": {
"@class": "com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo",
"name": "MyOwn"
},
}
}
data=json.dumps(request_body)
url="http://localhost:8090"
response = requests.post(url,data=json.dumps(request_body), headers = {'Content-type':'application/json'}).json()
print(response)
显示以下错误-
docker run -p 8443:8443 dockerpython {'timestamp': 1555717403333, 'status': 405, 'error': 'Method Not Allowed', 'exception': 'org.springframework.web.HttpRequestMethodNotSupportedException', 'message': "Request method 'POST' not supported", 'path': '/'}
我错过了什么?
这是 Eureka API 文档中的一个错误 - https://github.com/Netflix/eureka/wiki/Eureka-REST-operations. Once I tried same REST URLs without "/v2" , everything worked fine.enter image description here