ricardopereira / SocketIO-Kit

Socket.io iOS and OSX Client compatible with v1.0 and later

Home Page:https://ricardopereira.github.io/SocketIO-Kit

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Disconnection

chasseurmic opened this issue · comments

I am trying out the library and cannot understand why I get unexpected disconnections from the client that I cannot debug. The server (socket.io 1.3.5) gives me a disconnection warning, but on my iOS device the on(.Disconnected)() function never gets called. Any idea if this is an issue? The disconnection happens after a short time (some 20/30 sec) of inactivity on the socket.

The disconnection happens after a short time (some 20/30 sec) of inactivity on the socket.

I will make some tests. Can you create a small example of the server?

This is the server side (index.js) with express and socket.io as dependencies. It's very basic:

var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);

var devices = [];

app.get('/', function(req, res){
  res.sendFile(__dirname + '/index.html');
});

io.on('connection', function(socket){
  console.log('a user connected');

  socket.on('disconnect', function(){
    console.log('user disconnected');
  });

});

http.listen(3000, function(){
  console.log('listening on *:3000');
});

Thank you.

  • Which node version?
  • Are you running the server locally?
  • Are you using the simulator?

I'm suspicious that is a problem with the WebSocket heartbeat.

  • Node v0.12.2
  • localhost
  • running on the simulator

Hope it helps! Thanks.

Possible solution with #7

I replaced the WebSocket implementation. It was something that I wanted to do and I hope that it fixes this problem.

If your are using CocoaPods, please do pod update and test it again.
Thanks.

Seems to work right now. Good job! +1

Awesome!

I added a new event: TransportError.

Example:

on(.TransportError) {
    switch $0 {
    case .Failure(let error):
        println("WebSocket error: \(error)")
    default:
        break
    }
}