1

Hi I have two instances for ec2. One is for socket io and one is for my api requests. Both running with nginx.

I can access my socket io server in the browser. But I can not listen to it in my api server with this code in my api server:

var io = require('surespot-socket.io');
var http = require('http');
var server = http.createServer();
server.listen(socketPort, config.socket.host);
var socket = io.listen(server); 

config.socket.host is the host name of the server while socketPort is the port of the socket.

I am always getting this error from my api server:

warn  - error raised: Error: listen EADDRNOTAVAIL

Kindly help me. :(

objectiveCarlo
  • 372
  • 2
  • 16
  • Similar questions, several possible reasons: http://stackoverflow.com/questions/10809740/listen-eaddrnotavail-error-in-node-js and https://github.com/gruntjs/grunt-contrib-connect/issues/25 and http://stackoverflow.com/questions/6829563/nodejs-error-eaddrnotavail-cannot-assign-requested-address and http://askubuntu.com/questions/534196/node-js-websocket-error-error-listen-eaddrnotavail-error-listen-eaddrnotavail – jfriend00 Oct 21 '14 at 00:42
  • After reading these other answers, if you're trying to listen to the same port number from two different processes on the same machine (with the same IP address), you simply can't do that. Only one piece of code can listen to a given port number on a given IP address. – jfriend00 Oct 21 '14 at 01:11
  • hi the socket and api servers are in different instances. :( so they have different ips – objectiveCarlo Oct 21 '14 at 03:13
  • There are several other possibilities listed in those other articles. – jfriend00 Oct 21 '14 at 03:20

0 Answers0