Impossible to connect a client to a remote socket on AWS











up vote
3
down vote

favorite












I m facing an issue with an fresh dev with socket.io



I got a socket.io server that is running on a AWS EC2 instance. It's a single instance with a public (55.55.55.55) and a private ip address ( 10.0.1.1 ) on port 10000



I start the server, and then i go to a website i created on another EC2 instance which is in another VPC ( 10.5.1.1/16 ) and another public ip address 100.100.100.100



This is the code i run on this instance, the client side of the websocket ( display a simple chat test )



<script>
const display_panel = document.getElementById('ws');
const number_of_lines_displayed = document.getElementById('info_lines');

let socket = io('http://55.55.55.55:10000');

let line_counter = 0;

socket.on('test', (msg) => {

if(line_counter < {{ max_lines }})
{
let span = document.createElement('span');
let text = document.createTextNode(msg);
let newline = document.createElement('br');

span.appendChild(text);
display_panel.insertBefore(newline, display_panel.firstChild);
display_panel.insertBefore(span, display_panel.firstChild);

number_of_lines_displayed.innerHTML = 'line(s): ' + line_counter++;
}
});
</script>


Then , i got a connection timeout.



On the server side, i ve start the server trying all the possible solution , but i was not able to connect in all the situation




  • 10.0.1.1:10000

  • 127.0.0.1:10000

  • 0.0.0.0:10000

  • 55.55.55.55:10000


in this last case, the server give me this error



 Bugsnag:  Encountered an uncaught error, terminating…
1|test | Error: listen EADDRNOTAVAIL 55.55.55.55:10000
1|test | at Object._errnoException (util.js:992:11)
1|test | at _exceptionWithHostPort (util.js:1014:20)
1|test | at Server.setupListenHandle [as _listen2] (net.js:1338:19)
1|test | at listenInCluster (net.js:1396:12)
1|test | at doListen (net.js:1505:7)
1|test | at _combinedTickCallback (internal/process/next_tick.js:141:11)
1|test | at process._tickDomainCallback (internal/process/next_tick.js:218:9)
1|test | at Function.Module.runMain (module.js:695:11)
1|test | at startup (bootstrap_node.js:191:16)
1|test | at bootstrap_node.js:612:3


I don't see how i can make this thing working. As i m trying to reach public ip, i should not need a bridge between the VPC ( would be my favourite solution )



Netstat give me this in all case



Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 10.0.1.1:10000 0.0.0.0:* LISTEN 18132/test.js


Everything is working fine on local environment, so the code is not the issue, it look mainly to be a network issue.



Thanks for the help !










share|improve this question


























    up vote
    3
    down vote

    favorite












    I m facing an issue with an fresh dev with socket.io



    I got a socket.io server that is running on a AWS EC2 instance. It's a single instance with a public (55.55.55.55) and a private ip address ( 10.0.1.1 ) on port 10000



    I start the server, and then i go to a website i created on another EC2 instance which is in another VPC ( 10.5.1.1/16 ) and another public ip address 100.100.100.100



    This is the code i run on this instance, the client side of the websocket ( display a simple chat test )



    <script>
    const display_panel = document.getElementById('ws');
    const number_of_lines_displayed = document.getElementById('info_lines');

    let socket = io('http://55.55.55.55:10000');

    let line_counter = 0;

    socket.on('test', (msg) => {

    if(line_counter < {{ max_lines }})
    {
    let span = document.createElement('span');
    let text = document.createTextNode(msg);
    let newline = document.createElement('br');

    span.appendChild(text);
    display_panel.insertBefore(newline, display_panel.firstChild);
    display_panel.insertBefore(span, display_panel.firstChild);

    number_of_lines_displayed.innerHTML = 'line(s): ' + line_counter++;
    }
    });
    </script>


    Then , i got a connection timeout.



    On the server side, i ve start the server trying all the possible solution , but i was not able to connect in all the situation




    • 10.0.1.1:10000

    • 127.0.0.1:10000

    • 0.0.0.0:10000

    • 55.55.55.55:10000


    in this last case, the server give me this error



     Bugsnag:  Encountered an uncaught error, terminating…
    1|test | Error: listen EADDRNOTAVAIL 55.55.55.55:10000
    1|test | at Object._errnoException (util.js:992:11)
    1|test | at _exceptionWithHostPort (util.js:1014:20)
    1|test | at Server.setupListenHandle [as _listen2] (net.js:1338:19)
    1|test | at listenInCluster (net.js:1396:12)
    1|test | at doListen (net.js:1505:7)
    1|test | at _combinedTickCallback (internal/process/next_tick.js:141:11)
    1|test | at process._tickDomainCallback (internal/process/next_tick.js:218:9)
    1|test | at Function.Module.runMain (module.js:695:11)
    1|test | at startup (bootstrap_node.js:191:16)
    1|test | at bootstrap_node.js:612:3


    I don't see how i can make this thing working. As i m trying to reach public ip, i should not need a bridge between the VPC ( would be my favourite solution )



    Netstat give me this in all case



    Active Internet connections (only servers)
    Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
    tcp 0 0 10.0.1.1:10000 0.0.0.0:* LISTEN 18132/test.js


    Everything is working fine on local environment, so the code is not the issue, it look mainly to be a network issue.



    Thanks for the help !










    share|improve this question
























      up vote
      3
      down vote

      favorite









      up vote
      3
      down vote

      favorite











      I m facing an issue with an fresh dev with socket.io



      I got a socket.io server that is running on a AWS EC2 instance. It's a single instance with a public (55.55.55.55) and a private ip address ( 10.0.1.1 ) on port 10000



      I start the server, and then i go to a website i created on another EC2 instance which is in another VPC ( 10.5.1.1/16 ) and another public ip address 100.100.100.100



      This is the code i run on this instance, the client side of the websocket ( display a simple chat test )



      <script>
      const display_panel = document.getElementById('ws');
      const number_of_lines_displayed = document.getElementById('info_lines');

      let socket = io('http://55.55.55.55:10000');

      let line_counter = 0;

      socket.on('test', (msg) => {

      if(line_counter < {{ max_lines }})
      {
      let span = document.createElement('span');
      let text = document.createTextNode(msg);
      let newline = document.createElement('br');

      span.appendChild(text);
      display_panel.insertBefore(newline, display_panel.firstChild);
      display_panel.insertBefore(span, display_panel.firstChild);

      number_of_lines_displayed.innerHTML = 'line(s): ' + line_counter++;
      }
      });
      </script>


      Then , i got a connection timeout.



      On the server side, i ve start the server trying all the possible solution , but i was not able to connect in all the situation




      • 10.0.1.1:10000

      • 127.0.0.1:10000

      • 0.0.0.0:10000

      • 55.55.55.55:10000


      in this last case, the server give me this error



       Bugsnag:  Encountered an uncaught error, terminating…
      1|test | Error: listen EADDRNOTAVAIL 55.55.55.55:10000
      1|test | at Object._errnoException (util.js:992:11)
      1|test | at _exceptionWithHostPort (util.js:1014:20)
      1|test | at Server.setupListenHandle [as _listen2] (net.js:1338:19)
      1|test | at listenInCluster (net.js:1396:12)
      1|test | at doListen (net.js:1505:7)
      1|test | at _combinedTickCallback (internal/process/next_tick.js:141:11)
      1|test | at process._tickDomainCallback (internal/process/next_tick.js:218:9)
      1|test | at Function.Module.runMain (module.js:695:11)
      1|test | at startup (bootstrap_node.js:191:16)
      1|test | at bootstrap_node.js:612:3


      I don't see how i can make this thing working. As i m trying to reach public ip, i should not need a bridge between the VPC ( would be my favourite solution )



      Netstat give me this in all case



      Active Internet connections (only servers)
      Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
      tcp 0 0 10.0.1.1:10000 0.0.0.0:* LISTEN 18132/test.js


      Everything is working fine on local environment, so the code is not the issue, it look mainly to be a network issue.



      Thanks for the help !










      share|improve this question













      I m facing an issue with an fresh dev with socket.io



      I got a socket.io server that is running on a AWS EC2 instance. It's a single instance with a public (55.55.55.55) and a private ip address ( 10.0.1.1 ) on port 10000



      I start the server, and then i go to a website i created on another EC2 instance which is in another VPC ( 10.5.1.1/16 ) and another public ip address 100.100.100.100



      This is the code i run on this instance, the client side of the websocket ( display a simple chat test )



      <script>
      const display_panel = document.getElementById('ws');
      const number_of_lines_displayed = document.getElementById('info_lines');

      let socket = io('http://55.55.55.55:10000');

      let line_counter = 0;

      socket.on('test', (msg) => {

      if(line_counter < {{ max_lines }})
      {
      let span = document.createElement('span');
      let text = document.createTextNode(msg);
      let newline = document.createElement('br');

      span.appendChild(text);
      display_panel.insertBefore(newline, display_panel.firstChild);
      display_panel.insertBefore(span, display_panel.firstChild);

      number_of_lines_displayed.innerHTML = 'line(s): ' + line_counter++;
      }
      });
      </script>


      Then , i got a connection timeout.



      On the server side, i ve start the server trying all the possible solution , but i was not able to connect in all the situation




      • 10.0.1.1:10000

      • 127.0.0.1:10000

      • 0.0.0.0:10000

      • 55.55.55.55:10000


      in this last case, the server give me this error



       Bugsnag:  Encountered an uncaught error, terminating…
      1|test | Error: listen EADDRNOTAVAIL 55.55.55.55:10000
      1|test | at Object._errnoException (util.js:992:11)
      1|test | at _exceptionWithHostPort (util.js:1014:20)
      1|test | at Server.setupListenHandle [as _listen2] (net.js:1338:19)
      1|test | at listenInCluster (net.js:1396:12)
      1|test | at doListen (net.js:1505:7)
      1|test | at _combinedTickCallback (internal/process/next_tick.js:141:11)
      1|test | at process._tickDomainCallback (internal/process/next_tick.js:218:9)
      1|test | at Function.Module.runMain (module.js:695:11)
      1|test | at startup (bootstrap_node.js:191:16)
      1|test | at bootstrap_node.js:612:3


      I don't see how i can make this thing working. As i m trying to reach public ip, i should not need a bridge between the VPC ( would be my favourite solution )



      Netstat give me this in all case



      Active Internet connections (only servers)
      Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
      tcp 0 0 10.0.1.1:10000 0.0.0.0:* LISTEN 18132/test.js


      Everything is working fine on local environment, so the code is not the issue, it look mainly to be a network issue.



      Thanks for the help !







      amazon-web-services amazon-ec2 websocket socket.io






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 16 at 9:34









      Chris

      161




      161
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          Found the issue : We needed to open the port in the AWS console on the EC2 instance.



          Instance > security group > inbound rule






          share|improve this answer





















            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53335007%2fimpossible-to-connect-a-client-to-a-remote-socket-on-aws%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            0
            down vote













            Found the issue : We needed to open the port in the AWS console on the EC2 instance.



            Instance > security group > inbound rule






            share|improve this answer

























              up vote
              0
              down vote













              Found the issue : We needed to open the port in the AWS console on the EC2 instance.



              Instance > security group > inbound rule






              share|improve this answer























                up vote
                0
                down vote










                up vote
                0
                down vote









                Found the issue : We needed to open the port in the AWS console on the EC2 instance.



                Instance > security group > inbound rule






                share|improve this answer












                Found the issue : We needed to open the port in the AWS console on the EC2 instance.



                Instance > security group > inbound rule







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 19 at 13:49









                Chris

                161




                161






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.





                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                    Please pay close attention to the following guidance:


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53335007%2fimpossible-to-connect-a-client-to-a-remote-socket-on-aws%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    "Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

                    Alcedinidae

                    Origin of the phrase “under your belt”?