Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EXC_BREAKPOINT #20

Open
naartjie opened this issue Feb 19, 2015 · 4 comments
Open

EXC_BREAKPOINT #20

naartjie opened this issue Feb 19, 2015 · 4 comments

Comments

@naartjie
Copy link

I am getting an EXC_BREAKPOINT on this line

screen shot 2015-02-19 at 16 28 59

I am using socket.io v1.3.4, and engine.io v1.5.1, and SocketIOCocoa from master. On the server my code looks like this:

var socketio = require('socket.io'),
  io = socketio(server);

io.of('/brand/root').on('connection', function(socket) {

    var interval = setInterval(function() {
        console.log('sending foo');
        socket.emit('foo', {bar: 'baz'});
    }, 40*1000);

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

    socket.on('test', function(data, fn) {
        console.log('server got test event', data);
        fn('ack from server');
    });

    socket.emit('test', {server: 'from on.connection'}, function(data) {
        console.log('got ack from client', data);
    });
});

And on the client:

import Foundation

@objc class Sockets : NSObject, SocketIOSocketDelegate {

    func start() {
        var client = SocketIOClient(uri: "http://localhost:3000/socket.io/", reconnect: true, timeout: 30, transports: ["websocket"])
        client.open()
        var socket = client.socket("/brand/root")
        socket.delegate = self
    }

    func socketOnEvent(socket: SocketIOSocket, event: String, data: AnyObject?){
        println("got event \(event) \(data)")
    }

    func socketOnPacket(socket: SocketIOSocket, packet: SocketIOPacket) {
        println("socket packet \(packet.data))")
    }

    func socketOnOpen(socket: SocketIOSocket) {
        println("socket open")
        socket.event("test", data: [1, 2, 3]) { (packet) -> Void in
            println("got ack from server \(packet.data)")
        }
    }

    func socketOnError(socket: SocketIOSocket, error: String, description: String?) {
        println("socket error \(error)")
    }
}
@naartjie
Copy link
Author

screen shot 2015-02-19 at 16 51 00

The first screenshot is one stack level lower.

@naartjie
Copy link
Author

Hmm, when I change the connection line to use the defaults:

var client = SocketIOClient(uri: "http://localhost:3000/socket.io/")

It doesn't happen anymore.

But after a while the client gets disconnected on the server side:
screen shot 2015-02-19 at 17 35 34

While the client side doesn't seem to know anything about it. Well, there are no pings going backwards and forwards, but when I kill the server, Xcode console shows this:
screen shot 2015-02-19 at 17 40 21

I should have probably mentioned before, I am running this on the iOS Simulator (both client and server running on the same machine), do I need to tweak anything, or should it work out the box?

@naartjie
Copy link
Author

@shuoli84 I realise now that this is probably 2 separate issues. Unless it's something obvious I am doing wrong, I can move the second one into new issue.

@shuoli84
Copy link
Owner

from the code:

var client = SocketIOClient(uri: "http://localhost:3000/socket.io/", reconnect: true, timeout: 30, transports: ["websocket"])
        client.open()
        var socket = client.socket("/brand/root")
        socket.delegate = self

Seems you not retain any reference on client. Anyway, the lib should not crash. I'll fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants