10

I have developed an app (for IOS) written in react native which is working good in IPV4 networks. However, recently Apple has sent a message saying that my app did not work when tested in an IPV6 network. They told me that I had to make it compatible with IPV6-only networks too.

The question is, how can I make my existing API calls compatible with an IPV6 network?

My API uses the https protocol and it is called by domain name, not a raw IP.

A sample fetch call that I use is:

fetch(query,{
      method: 'post',
      headers: Utils.fetchHeaders('post')
      })
      .then(Utils.checkStatus)
      .then(Utils.parseJSON)
      .then(json => this._handleResponse(json))
      .catch(error => {

         this.setState({
          votingError: 'Sorry, there was an error!',
          loading: false
       });

      });

and the API endpoint is in following format:

https://www.myapidomain.com

any help appreciated.

meteorite
  • 736
  • 1
  • 8
  • 17

1 Answers1

7

The fetch API internally uses NSURLSession which already supports IPv6:

Most apps will not require any changes because IPv6 is already supported by NSURLSession and CFNetwork APIs.

Source: https://developer.apple.com/news/?id=05042016a

Since you're not using IPv4 addresses with the fetch API you should be good to go.

So I suspect there's something else (maybe some 3rd party code?) not cooperating with this. Did Apple provide you with more details about what was not working?

I suggest you follow this tutorial to test it on your side and find out what's incorrect.

Jean Regisser
  • 6,636
  • 4
  • 32
  • 32
  • 1
    It seems that my endpoint which is a digital ocean droplet does not accept connections from IPV6 networks. Although my domain is assigned with an IPV6 IP. There seems to be a networking issue with the droplet. I am talking to digital ocean to solve the issue. – meteorite Jun 29 '16 at 08:19
  • Ok I think i fixed it by enabling IPV6 support on my server however I do not understand why I have to make such a modification. Why can't I connect to an IPV4 server from within an IPV6-only network? any idea? – meteorite Jun 29 '16 at 12:15
  • I also doubt that the fetch API internally uses NSURLSession. Because why shouldn't it work by default then? The guy who reviewed my app on Apple side said that the app was working when he switched to an ipv4 network but did not work in ipv6-only network. Perhaps their network does not translate IPV4 ips to IPV6 or fetch actually does not use NSURLSession – meteorite Jun 29 '16 at 15:57
  • I can assure you `fetch` uses NSURLSession. – Jean Regisser Jun 29 '16 at 16:37
  • 1
    See [RCTHTTPRequestHandler](https://github.com/facebook/react-native/blob/235b16d93287061a09c4624e612b5dc4f960ce47/Libraries/Network/RCTHTTPRequestHandler.m#L19). You can add a breakpoint yourself there if you're not convinced. – Jean Regisser Jun 29 '16 at 16:48
  • You are right. But how can apple test apps from an IPV6 network that does not translate IPV4 ips to IPV6 ? isn't it strange? – meteorite Jun 29 '16 at 16:51
  • Yep that's strange, I don't know the reason yet. – Jean Regisser Jun 29 '16 at 17:00
  • 1
    Ok now I think I understand what was going on. In the beginning my domain name was assigned an AAAA record which pointed to my server. However, the server itself was not configured for IPV6 networking. I think Apple's reviewer resolved the AAAA record and tried to connect to my server which was not able to handle IPv6 requests until I set it up yesterday. I think if I had not added an AAAA record Apple wouldnt have had a problem connecting to my server because translation from IPv4 to IPv6 would have been necessary. – meteorite Jun 29 '16 at 23:26
  • Does older version of react native (0.23.0) work with ipv6 only networks – Ismail Iqbal Oct 18 '16 at 05:59
  • And also can I know which version of xcode was used to compile the source code. I am using xcode 7 (will this cause any ipv6 related issue) – Ismail Iqbal Oct 18 '16 at 15:15
  • The problem has nothing to do with react native or xcode version. The fetch Api works well with Ipv6 networks. The only thing you should care is you have to set up your server for IPV6 networking if you have added an AAAA record. – meteorite Dec 09 '16 at 15:05
  • Does Axios also support this? Can anyone confirm? – yanky_cranky Jul 19 '22 at 12:29