SwiftSocket icon indicating copy to clipboard operation
SwiftSocket copied to clipboard

Swift Socket not resolving dns in ios 11

Open sumeet-gluon opened this issue 8 years ago • 5 comments

  This code works till iOS 10. however it stopped working when I upgraded to iOS 11. I debugged and found the problem in ytcpsocket_connect.c gethostbyname() function is unable to resolve the DNS and the library always returns the queryFailed error. Please advise.

   var client = TCPClient(address: "device.abc.com", port: Int32(5001))
   switch client.connect(timeout: 5) {
                case .success:
                   print("connected")
                case .failure(let error):
                    print("Socker Error Reason - \(error)")
  }

sumeet-gluon avatar Sep 27 '17 00:09 sumeet-gluon

Same issue .. my app rejected bcz unable to resolve the ipv6 address

abbasqamar avatar Jan 10 '18 07:01 abbasqamar

Are there any updates to this issue? I have the exact same problem that no matter what address I put into the TCPClient, connecting always returns the queryFailed error.

I confirmed that mine was also acting up in the file "ytcpsocket.c" (Pods/SwiftSocket/ytcpsocket.c) in the function "ytcpsocket_connect". The issue is that after the call hp = gethostbyname(host) is executed, hp is always null, and thus returns -1.

Please, if someone has figured out how to move passed this, any help would be much appreciated!

HeartOfGold523 avatar Jul 17 '18 19:07 HeartOfGold523

I had to use the IP itself to connect. DNS name didn't work.

sumeet-gluon avatar Jul 17 '18 19:07 sumeet-gluon

@abbasqamar did you get any solution to connect via ipv6 address ? It gives me query failed error.

shirishbankar1 avatar Jul 08 '20 04:07 shirishbankar1