Sunday 15 June 2014

javascript - socket.io client side in node js -


Am I doing something wrong? I get this error message when I run node client.js :

  /web/ws/node_modules/socket.io/node_modules/engine.io/ Lib / server.js: 358 var listeners = server.listeners ('request') .slice (0); ^ Type error: object http: // localhost: 8080 does not have any method on the server 'listeners' .attach (/web/ws/node_modules/socket.io/node_modules/engine.io/lib/server.js:358 : 26) Function.attach (/web/ws/node_modules/socket.io/node_modules/engine.io/lib/engine.io.js:124:10) at server.listen.Server.attach (/ web / ws / Node_modules / socket .o / lib / index.js: 226: 21) on the server (/web/ws/node_modules/socket.io/lib/index.js:51:17) on the server (/ web / ws / node_modules / Socket Io / lib / index.js: 39: 41) on the object. & Lt; Anonymous & gt; (/web/ws/client.jsociety14) at Module._compile (module.js: 456: 26) at Object.Module._extensions..js (module.js: 474: 10) on Module.load (module.js: 356: 32) Function. Module._load (module .js: 312: 12)  

Here my code is:

  var Io = is required ('socket.io' ); Var Socket = Io ('ws: // localhost: 8080'); Socket.on ('connect', function) (socket.send ('hi'); socket.on ('message', function (msg) {// my msg})}});  

Please make some suggestions where I am making a mistake?

The problem here is that you have the package to configure the server is.

Instead you need to use the package to be able to act as a client.

You can find examples of usage by following the given links.


No comments:

Post a Comment