Android browser and io socket

I'm having trouble getting socket io to send a connection response for an Android browser. I registered the parameters, and they appear on the server side, it looks like the client side is not connected correctly. I disabled jsonp, but I heard that android is still returning to xhr.

socket.on('connect',function (data) { socket.emit('setNickAndRoom', {nick: nick}, function(response){ //response. nothing :(. }); }); client.on("setNickAndRoom", function(nick, fn,_){ //etc etc fn({msg :nick}); }); 

It works in every browser (even mobile safari, mobile FF, mobile chrome beta). I have to update the Android browser 4-5 times so that it finally connects. BTW, im using streamline js (_)

UPDATE This looks like wifi only

+7
source share
3 answers

Limited options currently:

http://code.google.com/p/weberknecht/

https://github.com/TooTallNate/Java-WebSocket

https://github.com/Gottox/socket.io-java-client

Sound right as far as WebSockets goes. The specific Socket.IO protocol does not seem to be implemented in Java yet, so you may have to deal with it yourself.

+3
source

Following the io website socket , it seems you are not using it correctly.

Try changing socket.on('connect',function (data) {

to

socket.on('connection',function (data) {

+1
source

For what it's worth, this simple example below works in my Android browser. Let us know if you need something specific that is not discussed below - it is important: Change the IP number and port to whatever suits your environment:

 var express = require('express'), socketio = require('socket.io'), app = express.createServer(), io = socketio.listen(app); var index = "<!doctype html>\ <html>\ <head>\ <script src=/socket.io/socket.io.js></script>\ <script>\ var socket = io.connect('http://10.0.1.29:3000');\ function send() {\ socket.emit('foo', 'Ben', function(data) {\ alert(data);\ });\ }\ </script>\ </head>\ <body>\ <button onclick='send();'>Send</button>\ </html>"; app.get('/', function(req, res) { res.send(index); }); io.sockets.on('connection', function(socket) { socket.on('foo', function(name, f) { f('Hello ' + name); }); }); app.listen(3000); 
0
source

All Articles