britztopher britztopher - 7 days ago 6
Node.js Question

400 from Eureka js client with Amazon

For some reason Im getting a 400 back when registering with a Eureka on Amazon. At first I thought it had to do with the known issue with eureka js client, however, after apply the fixes for that issue it works locally, but not when datacenter object is Amazon. It seems to fetch the metadata from amazon, applies it to the eureka-js-client config object using local, then make the POST request, but it seems to respond with 400 status.

Here is my config object:



instance: {
app: 'my-node-service',
port: {
'$': 8201,
'@enabled': true
},
vipAddress: 'myapp.awesome.com',
statusPageUrl: 'http://__HOST__:8201/info',
dataCenterInfo: {
'@class': 'com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo',
name: 'Amazon',
}
},
eureka: {
useLocalMetadata: true,
ssl: true,
// eureka server host / port
serviceUrls: {
default: [
'https://myamazoneurekaserver.com/eureka/apps',
'https://myamazoneurekaserver1.com/eureka/apps',
'https://myamazoneurekaserver2.com/eureka/apps'
]
},
servicePath: '/eureka/apps/'
},
}





which results in this ouput from EurekaClient.js file:


Error: eureka registration FAILED: status: 400 body: [object Object]
at /usr/app/node_modules/eureka-js-client/lib/EurekaClient.js:267:23
at Request.self.callback (/usr/app/node_modules/request/request.js:186:22)
at /usr/app/node_modules/async/dist/async.js:484:16
at nextTask (/usr/app/node_modules/async/dist/async.js:5195:29)
at /usr/app/node_modules/async/dist/async.js:5202:13
at apply (/usr/app/node_modules/async/dist/async.js:41:25)
at /usr/app/node_modules/async/dist/async.js:76:12
at /usr/app/node_modules/async/dist/async.js:988:16
at Request._callback (/usr/app/node_modules/eureka-js-client/lib/EurekaClient.js:570:9)
at /usr/app/node_modules/eureka-js-client/lib/EurekaClient.js:592:7


Any reason why this would occur. The examples that use
Amazon
dont use default service Urls but this works locally when I use
MyOwn
as
dataCenterInfo
name.

JQ- JQ-
Answer

Answered this in the GitHub issue as well, but putting it here for posterity =).

For Amazon datacenters (and the newer eureka JSON format), I think you'll need to pass a different value for @class. Try using: com.netflix.appinfo.AmazonInfo.

If you still get a bad request, sometimes it helps to make the request manually to the service (since that's all this client does), if you have Postman or a similar tool, that would work. You can also set NODE_DEBUG=request to see what's happening at the request level in the client.