nuclearace / Socket.IO-Client-Swift

socket.io-client for Swift
Other
361 stars 53 forks source link

SocketIO-client-Swift library(Version 13) is not connecting socket for iOS #148

Open PrasannaYuvitime opened 6 years ago

PrasannaYuvitime commented 6 years ago

I am trying to connect socket but connect listener not getting called so as a result socket not getting connected....

Got this error while configuring process for this library which I resolved by doing... https://i.stack.imgur.com/xpQc7.png

private lazy var logType = "SocketIOClient{(nsp)}"`

Earlier It was... private lazy var logType = "SocketIOClient{\(nsp)}"

Used below code to establish connection.... while I was able to connect on this library's version 10.

The back end team says - "The socket connects perfectly and after few seconds it disconnects automatically".

I also verified for the case of manual disconnection on code but not found any possible aspect... Not getting any idea to resolve this ..Need Help!!!

NSString *strToken = [[[NSUserDefaults standardUserDefaults] objectForKey:kUserDetailsFromPreferance] objectForKey:kAuth_Token];
SocketManager* manager = [[SocketManager alloc] initWithSocketURL:[NSURL URLWithString:[NSString stringWithFormat:kChatServer]]
                                                          config:@{@"log": @YES,@"connectParams": @{@"Authorization":strToken}}];
self.socket = manager.defaultSocket;
[self.socket connect];

My console logs....

2017-11-23 17:51:32.986396+0530 [8044:2460214] Reachability Flag Status: -R ------- networkStatusForFlags
2017-11-23 17:51:32.989188+0530 [8044:2460214] Network Status =Reachable WiFi
2017-11-23 17:51:33.036545+0530 [8044:2460068] LOG SocketIOClient{(nsp)}: Handling event: statusChange with data: [connecting]
2017-11-23 17:51:33.036815+0530 [8044:2460068] LOG SocketManager: Tried connecting socket when engine isn't open. Connecting
2017-11-23 17:51:33.036879+0530 [8044:2460068] LOG SocketManager: Adding engine
2017-11-23 17:51:33.041499+0530 [8044:2460068] LOG SocketIOClient{(nsp)}: Adding handler for event: disconnect
2017-11-23 17:51:33.041600+0530 [8044:2460203] LOG SocketEngine: Starting engine. Server: http://192.168.0.107:3001/
2017-11-23 17:51:33.041667+0530 [8044:2460203] LOG SocketEngine: Handshaking
2017-11-23 17:51:33.041758+0530 [8044:2460068] LOG SocketIOClient{(nsp)}: Adding handler for event: connect
2017-11-23 17:51:33.041841+0530 [8044:2460068] LOG SocketIOClient{(nsp)}: Adding handler for event: incoming_message
2017-11-23 17:51:33.041910+0530 [8044:2460068] LOG SocketIOClient{(nsp)}: Adding handler for event: message_delivered
2017-11-23 17:51:33.041976+0530 [8044:2460068] LOG SocketIOClient{(nsp)}: Adding handler for event: chat receive_typing
2017-11-23 17:51:33.042037+0530 [8044:2460068] LOG SocketIOClient{(nsp)}: Adding handler for event: get_user_status
2017-11-23 17:51:33.042093+0530 [8044:2460068] LOG SocketIOClient{(nsp)}: Adding handler for event: scheduler receive_notification
2017-11-23 17:51:33.042196+0530 [8044:2460068] LOG SocketIOClient{(nsp)}: Adding handler for event: scheduler welcome_notification
2017-11-23 17:51:33.042252+0530 [8044:2460068] LOG SocketIOClient{(nsp)}: Adding handler for event: new_group_creation
2017-11-23 17:51:33.042312+0530 [8044:2460068] LOG SocketIOClient{(nsp)}: Adding handler for event: call receive_audio_video_call_status
2017-11-23 17:51:33.042366+0530 [8044:2460068] LOG SocketManager: Manager is being released
2017-11-23 17:51:33.043169+0530 [8044:2460203] LOG SocketEnginePolling: Doing polling GET http://192.168.0.107:3001/socket.io/?transport=polling&b64=1&Authorization=JWT%20eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI1OTk2ZTAyYmVlMjZiNDAyMmM0YmJiNGIiLCJpYXQiOjE1MTE0MzQ0MDksImF1ZCI6Ill1dml0aW1lLmNvbS5hdSIsImlzcyI6Ill1dml0aW1lLmNvbSJ9.UQ-jAL5tWqbg0bjLN3Bq42flKwLovQ6lpr72LexWnwqgr1Tpw03Uf1RM-I51L_WwGPnYooottSqiqQLP0UxvJ_3ejddC2pBR2Zu_UUSdaqhRU1xVCKtPeMv-P4ctRPzUu0qq-ySKNWZI9wb1XrSADQ0lKdfXqkPB39_2k73TfiAlhQ4O_CA7pdfwQ9p2b6KFf3gpTvJe_JQX1Boz7TamPso3rGvK97Q0v0kJ7Pb01axsFDH5vxRUca1upaOK1-FrWOdlY3iWJwzxHtDWsgzeVfStSv-GQmE-mdu7J0QYdBNY8DekSV5OY3sx9mfOvplkM9bLY8EHEWAcT4UQ_cdXtg
2017-11-23 17:51:33.074124+0530 [8044:2460068] -[AppDelegate applicationDidBecomeActive:]
2017-11-23 17:51:33.074203+0530 [8044:2460068] SocketIOClientStatus 2
2017-11-23 17:51:33.078545+0530 [8044:2460183] LOG SocketEnginePolling: Got polling response
2017-11-23 17:51:33.078851+0530 [8044:2460183] LOG SocketEnginePolling: Got poll message: 96:0{"sid":"gg5eNok9X4K82OOzAAAK","upgrades":["websocket"],"pingInterval":3000,"pingTimeout":10000}
2017-11-23 17:51:33.080744+0530 [8044:2460183] LOG SocketEngine: Got message: 0{"sid":"gg5eNok9X4K82OOzAAAK","upgrades":["websocket"],"pingInterval":3000,"pingTimeout":10000}
2017-11-23 17:51:33.094501+0530 [8044:2460183] LOG SocketEngine: Writing poll:  has data: false
2017-11-23 17:51:33.094614+0530 [8044:2460183] LOG SocketEnginePolling: Sending poll:  as type: 2
2017-11-23 17:51:33.099496+0530 [8044:2460183] LOG SocketEnginePolling: Created POST string: 1:2
2017-11-23 17:51:33.099926+0530 [8044:2460183] LOG SocketEnginePolling: POSTing
2017-11-23 17:51:33.102227+0530 [8044:2460203] LOG SocketEngine: Engine is being released

@nuclearace please help me on this ,I am not getting any idea to solve this ,please let me know if more explanations required... @nuclearace

kangsircome commented 6 years ago

strong retain the socketManager