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

Objective-C : Cant connect to server using Socket.IO #167

Open
harshanakaru opened this issue May 31, 2018 · 1 comment
Open

Objective-C : Cant connect to server using Socket.IO #167

harshanakaru opened this issue May 31, 2018 · 1 comment

Comments

@harshanakaru
Copy link

Hi,

I'm using Socket.IO-Client-Swift' -13.2.0' to implement my project in Objective-C. I'm trying to connect to a Node.js service using Socket.IO and have followed the documentation for Objective-C. But when i try to run my code, the console logs 'tried connecting socket when engine isn't open' and cant get through.

Following is my code,

@import SocketIO;
NSURL* url = [[NSURL alloc] initWithString:@"http://URL_STRING:PORT_NUMBER"];

SocketManager *manager = [[SocketManager alloc] initWithSocketURL:url config:@{@"log":@yES, @"compress":@yES}];
SocketIOClient *socket = [manager defaultSocket];

[socket on:@"connect" callback:^(NSArray* data, SocketAckEmitter* ack) {
NSLog(@"socket connected");
}];

[socket connect];

And the console,


2018-06-01 00:22:06.694853+1000 [885:732318] LOG SocketIOClient{/}: Adding handler for event: connect
2018-06-01 00:22:06.695467+1000 [885:732318] LOG SocketIOClient{/}: Handling event: statusChange with data: [connecting]
2018-06-01 00:22:06.695578+1000 [885:732318] LOG SocketIOClient{/}: Joining namespace /
2018-06-01 00:22:06.695639+1000 [885:732318] LOG SocketManager: Tried connecting socket when engine isn't open. Connecting
2018-06-01 00:22:06.695679+1000 [885:732318] LOG SocketManager: Adding engine
2018-06-01 00:22:06.697262+1000 [885:732355] LOG SocketEngine: Starting engine. Server: http://URL_STRING:PORT_NUMBER
2018-06-01 00:22:06.697323+1000 [885:732355] LOG SocketEngine: Handshaking
2018-06-01 00:22:06.699886+1000 [885:732355] LOG SocketEnginePolling: Doing polling GET http://URL_STRING:PORT_NUMBER/socket.io/?transport=polling&b64=1

How to solve this issue?
Thanks.

@yongwumai
Copy link

you have to keep manager alive

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