Skip to content

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

@harshanakaru

Description

@harshanakaru

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions