按照Eureka API文档注册非Java App-问题

时间:2019-04-22 19:04:44

标签: netflix-eureka

我的Eureka在我的localhost:8090中运行。我已经在该Eureka中注册了独立的Java应用程序,并且能够使用我的Zuul URL访问它们,该URL也已注册到该Eureka。

现在我有另一个Python(3.7.3)+ Flask应用程序,我正在尝试在相同的Eureka中注册并通过相同的Zuul URL进行访问。 使用以下命令,我的Python应用通过DOCKERFILE在本地运行良好-

EXPOSE 8443
CMD ["python", "PythonFlaskSample.py"]

这会打开一个包含此URL的网页- http://localhost:8443/home

然后在Eureka中注册该应用程序,我遵循了此文档-

https://github.com/Netflix/eureka/wiki/Eureka-REST-operationshttps://automationrhapsody.com/json-format-register-service-eureka/

还尝试通过具有POST URL的REST客户端通过- 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"
        },
    }
}

但是对于Restlet客户或Postman中发生的事情,它抛出405,没有其他线索。

当我尝试将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,   '状态':405,'错误':'方法不允许','例外':   'org.springframework.web.HttpRequestMethodNotSupportedException',   'message':“不支持请求方法'POST'”,'path':'/'}

我想念什么?

1 个答案:

答案 0 :(得分:0)

这是-https://github.com/Netflix/eureka/wiki/Eureka-REST-operations中Eureka API文档的错误。一旦尝试了不带“ / v2”的相同REST URL,一切都将正常工作。enter image description here