error on connecting to the server : socket io is not defined

Posted by max on Stack Overflow See other posts from Stack Overflow or by max
Published on 2012-07-07T21:03:54Z Indexed on 2012/07/07 21:15 UTC
Read the original article Hit count: 291

Filed under:
|
|

i know there's been couple of question about the same problem , i've already check them .

i have very simple node.js chat app

i have a server running on 8000 port and it works fine

my client pages are html , they are running on apache and i'm using socket.io to connect them to the server and it works fine on the local host

but when i upload the app on the server i keep on getting this error in the firebug

io is not defined
var socket = io.connect('http://atenak.com:8000/');

or sometimes it doesn't show that but when i try to broadcast message from cliend i get this error :

socket is undefined
socket.emit('msg', { data: msg , user:'max' });

the only difference is i've changed the localhost with atenak.com !

here is my html code

var socket = io.connect('http://atenak.com:8000/');
    var user = 'jack';
  socket.on('newmsg', function (data) {
       if(data.user == user )
       {
           $('#container').html(data.data);
       }
  });

     function brodcast(){
           var msg = $('#fild').val();
          socket.emit('msg', { data: msg , user:'max' });
      }

</script>
</head>
<body>
<div id="container">  </div>
   <input id="fild"  type="text">  <input name="" type="button" onClick="brodcast();">

</body> 

i have included the sockt.io.js and server is running ok which means socket.io is installed on the server

here is the live page

http://atenak.com/client.html

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about node.js