Tuesday 15 May 2012

node.js - Error in socket.io programming of handshaking in android -



node.js - Error in socket.io programming of handshaking in android -

i have created server.js file , have run

npm install socket.io

and have used gottox illustration communicate socket android device getting error of handshaking. please help me out.

here server.js file

//settings var websocketport = 8080; // start websockets var io = require('socket.io').listen(websocketport); console.log('chat server running on port ' + websocketport); //websocket communication io.sockets.on('connection', function(socket){ // tell clients has connected var ipaddress = socket.handshake.address.address; io.sockets.emit('chat', {name: ipaddress, text: 'joined chat'}); console.log('client [' + ipaddress + '] connected'); // relay message of client other clients socket.on('chat', function(data){ io.sockets.emit('chat', {name: data.name, text: data.text}); }); // tell clients has disconnected socket.on('disconnect', function(){ io.sockets.emit('chat', {name: ipaddress, text: 'left chat'}); console.log('client [' + ipaddress + '] disconnected'); }); });

and have used gottox/socket-io-client communicating socket android device . code below

final socketio socket = new socketio("http://192.168.2.24:8080"); socket.connect(new iocallback() { @override public void onmessage(jsonobject arg0, ioacknowledge arg1) { seek { log.e("tag","server said:" + arg0.tostring(2)); } grab (jsonexception e) { // todo auto-generated grab block e.printstacktrace(); } } @override public void onmessage(string arg0, ioacknowledge arg1) { log.e("tag","server said:" + arg0); } @override public void onerror(socketioexception arg0) { log.e("tag","an error " + arg0); } @override public void ondisconnect() { log.e("tag","connection terminated "); } @override public void onconnect() { log.e("tag","connection established "); socket.emit("connection", socket); } @override public void on(string arg0, ioacknowledge arg1, object... arg2) { log.e("tag","server started " + arg0); } }); // socket.send("user message"); socket.emit("connection", socket); } grab (malformedurlexception e) { // todo auto-generated grab block e.printstacktrace(); } }

everytime connecting getting error while handshaking.

11-07 17:00:03.475: e/tag(2524): error io.socket.socketioexception: error while handshaking 11-07 17:00:03.475: i/io.socket(2524): cleanup

android node.js sockets android-layout

No comments:

Post a Comment