nuclearace / socket.io-client-swift-example

An example of socket.io-client for Swift
176 stars 65 forks source link

No connection with simulator and localhost #20

Open hrabkin opened 2 years ago

hrabkin commented 2 years ago

I tried to run the sample using simulator and localhost server but app unable to connect, see the screenshot below:

Screenshot 2021-10-20 at 14 05 06

I am not sure is it a problem of iOS simulator restrictions or maybe Info.plist can be tweaked somehow to allow connections to localhost (something with ATS - apple transport security)?

I wanted to check that your sample works OK and then start modifying it as a base template to my needs but I can't pass the first milestone and verify that socket.io works with iOS. I am pretty sure it does but I couldn't verify it for myself with your sample.

What I tried so far:

  1. I tried to follow this answer for react native app connection issue with socket.io but with no luck I then receive another type of error mentioned here
  2. I tried with real device in combination with (1) but still same issue
  3. I tried to set forced update as here proposed in READ.me pod 'Socket.IO-Client-Swift', '~> 15.2.0'

P.S. I want to assure you that I followed your FAQ and didn't modify code of your sample (only for trying (1) and changing server address), so manager instance is global

hrabkin commented 2 years ago

I finally make it work by deploying your sample server on EC2 aws instance

2021-10-20 17:27:08.995517+0300 TicTacIOiOS[2132:739939] [connection] nw_endpoint_handler_set_adaptive_write_handler [C1.1 3.120.138.117:3000 ready channel-flow (satisfied (Path is satisfied), viable, interface: en0, ipv4, dns)] unregister notification for write_timeout failed
2021-10-20 17:27:09.044208+0300 TicTacIOiOS[2132:739941] LOG SocketEnginePolling: Got polling response
2021-10-20 17:27:09.044344+0300 TicTacIOiOS[2132:739941] LOG SocketEnginePolling: Got poll message: 96:0{"sid":"6qKEUSgXoUOp9PSkAAAB","upgrades":["websocket"],"pingInterval":25000,"pingTimeout":5000}2:40
2021-10-20 17:27:09.044985+0300 TicTacIOiOS[2132:739941] LOG SocketEngine: Got message: 0{"sid":"6qKEUSgXoUOp9PSkAAAB","upgrades":["websocket"],"pingInterval":25000,"pingTimeout":5000}
2021-10-20 17:27:09.050941+0300 TicTacIOiOS[2132:739941] LOG SocketEngine: Got message: 40
2021-10-20 17:27:09.050962+0300 TicTacIOiOS[2132:739924] LOG SocketIOClient{/}: Handling event: ping with data: []
Got event: ping, with items: []
2021-10-20 17:27:09.051138+0300 TicTacIOiOS[2132:739924] LOG SocketManager: Engine opened Connect
2021-10-20 17:27:09.051207+0300 TicTacIOiOS[2132:739924] LOG SocketIOClient{/}: Socket connected
2021-10-20 17:27:09.051280+0300 TicTacIOiOS[2132:739924] LOG SocketIOClient{/}: Handling event: statusChange with data: [connected, 3]
Got event: statusChange, with items: [connected, 3]
2021-10-20 17:27:09.051335+0300 TicTacIOiOS[2132:739941] LOG SocketEnginePolling: Doing polling GET