1

There is a node.js service listening on port:8080 and my asp.net mvc application needs to communicate with node.js service using socket.io

This works fine in local host. But getting 502 and 522 error codes after publishing both mvc and node.js projects in my AWS EC2 instance.

Errors Node.js

 var jsonfile = require('jsonfile');
    var app = require('express')();
    var http = require('http').Server(app);
    var XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
    var xhr = new XMLHttpRequest();
    var querystring = require('querystring');
    var io = require('socket.io')(http);
    var uniqid = require('uniqid');

    io.set('origins', 'www.mydomain.com:80');
Gausul
  • 265
  • 3
  • 16
Oshada Ekanayake
  • 360
  • 1
  • 2
  • 12

2 Answers2

1

you can try:

io.set('origins', '*:*');

Read More About origins

Gausul
  • 265
  • 3
  • 16
  • @OshadaEkanayake ok try this: io.origins('*:*') ; – Gausul Jun 23 '18 at 02:11
  • @OshadaEkanayake Please check your firewall settings i think your port not enable. – Gausul Jun 23 '18 at 02:28
  • I checked the port 8080 with telnet client. but port 8080 is not blocked – Oshada Ekanayake Jun 23 '18 at 02:37
  • Issue is fixed after adding a firewall inbound rule for port 8080. Thanks for your support :) – Oshada Ekanayake Jun 23 '18 at 02:52
  • @OshadaEkanayake - This is a bit odd because you accepted this answer (perhaps because Gausul did help you), but the answer itself does not describe the actual solution. It seems that either Gausul should edit the answer to include the actual solution or you should accept your answer which is the solution. So, if one reads your question and the accepted answer, you don't actually get a correct impression of what the solution to the problem was. It's not supposed to be that way. – jfriend00 Jun 23 '18 at 05:23
  • @jfriend00 Sorry I'm new for stackoverflow. I posted the answer but I can't mark it as correct answer myself – Oshada Ekanayake Jun 23 '18 at 06:43
  • @OshadaEkanayake - You can accept your own answer after 48 hours. See: [Can I Answer My Own Question - Help Center](https://stackoverflow.com/help/self-answer). – jfriend00 Jun 23 '18 at 07:03
1

Issue is resolved after adding a firewall inbound rule for port 8080.

Oshada Ekanayake
  • 360
  • 1
  • 2
  • 12