0

I have implemented the Reachability class successfully. However, in my app I'd like to notify the user when a connection to our server only can't be made (but the regular internet is working).

Reachability is reporting that the iPhone successfully can reach a hostname, when I thought it might return an error b/c I was not on an authenticated network:

The hostname I use is 'foreverfreebank.com'. Again, Reachability's hostname check reports success.

However,

--to access this site via the web, one needs to use https in the browser, i.e. 'https://foreverfreebank.com'

Does Reachability account for this case? Or does the protocol part ('https') not count for anything?

I am confused b/c if you type in in the Firefox browser 'http://foreverfreebank.com', (leaving out the 's'), you get an error. That is, http:// should NOT be reachable.

Similarly, I have another site that requires VPN access to get to the site: http://checksforever.com. When I try the hostname: 'checksforever.com', Reachability reports success even though I am not on VPN.

Is this expected behavior? Thanks

user798719
  • 9,619
  • 25
  • 84
  • 123

1 Answers1

1

You need to check reachability on a specific port (443 in this case). This is something that is not supported by Reachability API. Refer to this question, or this.

Relevant part from documentation:

A remote host is considered reachable when a data packet, sent by an application into the network stack, can leave the local device. Reachability does not guarantee that the data packet will actually be received by the host.

So, basically Reachability doesn't test if the remote host accepts incoming connections. For this purpose, I suspect you'll need to open an URL connection and wait for time out/other errors.

Community
  • 1
  • 1
maroux
  • 3,764
  • 3
  • 23
  • 32
  • Thanks for these links. There is a clear distinction that needs to be made which I am unaware of. Reachability means that the iPhone can send a packet out, but it says nothing about whether the host can reply (aka a ping function). What is the point of the remote host function then vs the check general internet connectivity? – user798719 Jun 08 '13 at 21:40
  • Reachability goes one step further than a simple check on whether WiFi/3G is connected. (Now that I think about it, it's the only way to check for WiFi connection, is it not?). Perhaps https://developer.apple.com/library/mac/#samplecode/SimplePing/Introduction/Intro.html#//apple_ref/doc/uid/DTS10000716-Intro-DontLinkElementID_2 could help you. – maroux Jun 09 '13 at 07:45