node.js - Reaching a server from outside the network -


i tried run nodejs chat demo , test it. worked on same computer program running on, chat couldn't reached outside. code server:

    var websocketserver = require('ws').server     var wss = new websocketserver({host: 'put_my_ip_in_here',port: 8000});     wss.on('connection', function(ws)     {         console.log('client connected...');         ws.on('message', function(message)         {             console.log('received client: ' + message);             ws.send('received server: ' + message);         });     }); 

i unblocked port 8000 (udp , tcp in router , firewall , told outside network open following page

<!doctype html> <html> <head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function() {     function connect()     {         var socket = new websocket("ws://put_my_ip_in_here:8000");         socket.onopen   = function()    { message('socket status: '+socket.readystate+' (open)');   }         socket.onmessage= function(msg) { message('received: '+msg.data);                           }         function send()         {             var text = $('#text').val();             socket.send(text);             message('sent : '+text)             $('#text').val("");         }         {             $('#log').append(msg+'</br>');         }         $('#text').keypress(function(event)         {             if (event.keycode == '13')             {                 send();             }         });     }      connect();  }); </script> </head> <body>     <div id="container">         <div id="log"></div>         input: <input id="text" type="text" />     </div> </body> </html> 

but computer/the chat wasnt reachable :c problem? demos seems running fine!


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -