nowelium / socket.io-titanium

socket.io for titanium mobile
http://youtu.be/10ogNjWCpyc
Other
136 stars 34 forks source link

Unable to Get Demo Working on Android #11

Closed joelongstreet closed 12 years ago

joelongstreet commented 12 years ago

I'm wondering if there's some kind of special trick to get this running on Android. I got it first try on iPhone, but regardless of what I do on Android I get the same error:

Runtime Error

Location : [132,32] ti:/bootstrap.js Uncaught Error: Invalid value, expected type Number Source : return Titanium.clearTimeout.apply(Titanium, arguments)

I get this same error on my physical Android device. I have a remote web server with sockets enabled and it works fine with iOS.

If the web server socket is not running, I get no error.

joelongstreet commented 12 years ago

So.....

are you using a specific version of titanium maybe?

joelongstreet commented 12 years ago

Well, it looks like an issue between lines 271 and 278 of socket.io/lib/socket.js. If you move the clearTimeout below the heartbeatTimeoutTimer definition it will stop complaining and work.

zhaoqy commented 12 years ago

android setTimeout must before clearTimeout fix it like this in socket.io/lib/socket.js lines 271 to 278 /////////////// Socket.prototype.setHeartbeatTimeout = function () { if(this.heartbeatTimeoutTimer) clearTimeout(this.heartbeatTimeoutTimer); var self = this; this.heartbeatTimeoutTimer = setTimeout(function () { self.transport.onClose(); }, this.heartbeatTimeout); }; /////////////// and others maybe the same problem,fix it

joelongstreet commented 12 years ago

Closing this issue as it's not a direct problem with the library.

farfromrefug commented 11 years ago

I just faced this problem, we should propose a fix to socket.io!