question

newuser-947e842b-2a51-47d8-bd6b-a303587233ae avatar image
newuser-947e842b-2a51-47d8-bd6b-a303587233ae asked ·

Opening a downchannel stream using nodejs gives Error: connect ECONNREFUSED?

I'm trying to establish a downchannel stream with AVS using the http2 module for nodejs.

This is my current request:

// open downchannel stream to AVS

	var options = {
		method: 'GET',
		scheme: 'https',
		host: 'avs-alexa-na.amazon.com',
		path: '/v20160207/directives',
		port: 80, 			
		auth: 'Bearer ' + token			
	};

	var req = http2.request(options, (res) => {
		console.log('statusCode: ', res.statusCode);
		console.log('headers: ', res.headers);
		res.on('data', (d) => {
			process.stdout.write(d);
		});
	});

	req.on('error', (e) => {
		console.error(e);
	});

	req.end();

This is the error code that I receive:

{ [Error: connect ECONNREFUSED 54.239.21.157:80]
  code: 'ECONNREFUSED',
  errno: 'ECONNREFUSED',
  syscall: 'connect',
  address: '54.239.21.157',
  port: 80 }

Does anyone know what's going on here?

alexa voice servicenode_js
10 |2000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Hao@Amazon avatar image
Hao@Amazon answered ·

Hi,

Have you tried sending events without establishing the down channel? Another thing to check is if your NodeJS support http2?

10 |2000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Lasse Sprengel avatar image
Lasse Sprengel answered ·

Try using port 443 (Default for encrypted traffic) instead of 80.

I tried using http2 as well and had some troubles. I then switched to spdy, which is able to connect but I am getting only empty (204) responses.

Let me know if you find a solution :)

10 |2000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.