Problem with aws-sdk, TimeoutError


#1

I’m trying to use the aws-sdk. In server/main.js I’m trying to call describeLoadBalancers()

import { Meteor } from 'meteor/meteor';
import AWS from 'aws-sdk';

Meteor.startup(() => {
	// code to run on server at startup
	//check for configuration
	if (! Meteor.settings.aws)
	{
		console.log("WARNING: Configuration not found");
	} else {
		console.log("accessKeyId: " + Meteor.settings.aws.accessKeyId);

		AWS.config.update({
			accessKeyId: Meteor.settings.aws.accessKeyId,
			secretAccessKey: Meteor.settings.aws.secretAccessKey,
			region: Meteor.settings.aws.secretAccessKey,
			httpOptions: {timeout:5000}
		});

		var elb = new AWS.ELB();
		var params = { LoadBalancerNames: ['my-loadbalancer']};
		elb.describeLoadBalancers(params, function (err, data) {
			if (err)
				console.log(err, err.stack); // an error occurred
			else
				console.log(data);           // successful response
		});

		

		console.log("exiting startup()...");
	}
});

but I just get this error:


=> App running at: http://localhost:3000/
I20161022-16:11:46.300(-7)? { [TimeoutError: Connection timed out after 5000ms]
I20161022-16:11:46.301(-7)?   message: 'Connection timed out after 5000ms',
I20161022-16:11:46.301(-7)?   code: 'NetworkingError',
I20161022-16:11:46.301(-7)?   time: Sat Oct 22 2016 16:11:46 GMT-0700 (PDT),
I20161022-16:11:46.301(-7)?   region: 'OKBKWimGimO7R1e1s8rCfUDYFe46leGvFe7waXRH',
I20161022-16:11:46.301(-7)?   hostname: 'elasticloadbalancing.okbkwimgimo7r1e1s8rcfudyfe46legvfe7waxrh.amazonaws.com',
I20161022-16:11:46.301(-7)?   retryable: true } 'TimeoutError: Connection timed out after 5000ms\n    at ClientRequest.<anonymous> (/Users/phil/Projects/server-console/node_modules/aws-sdk/lib/http/node.js:56:34)\n    at ClientRequest.g (events.js:260:16)\n    at emitNone (events.js:67:13)\n    at ClientRequest.emit (events.js:166:7)\n    at TLSSocket.emitTimeout (_http_client.js:575:10)\n    at TLSSocket.g (events.js:260:16)\n    at emitNone (events.js:67:13)\n    at TLSSocket.emit (events.js:166:7)\n    at TLSSocket.Socket._onTimeout (net.js:332:8)\n    at _runOnTimeout (timers.js:524:11)'

I’m able to run the aws-cli in my terminal file so I think the network connection is ok. What could be the issue?


#2

Nevermind. I see I passed a wrong value for region to AWS.config.update()