Reachability.swift icon indicating copy to clipboard operation
Reachability.swift copied to clipboard

'hostname' with a port, possible?

Open ReveelTeam opened this issue 6 years ago • 4 comments

First off, thanks for the work.

Just getting started here, and all seems okay except when I am trying to keep track of a specific server URL (on a port) via hostname parameter. I am keeping track for 2 Reachability's, one for the device's network (i.e "let networkReachability = Reachability()!") and also a specific server URL (see below). The issue is on the server URL attempt, which has a specific DNS with a port number over HTTPS. Noticed that a regular HTTPS or HTTP hostname string (w/o port) will work but not with a port added.

Format attempted to use (didn't work): let filesServerReachability = Reachability(hostname: "https://files.ServerURL.com:6060")!

This does work though: let hostnameReachability = Reachability(hostname: "https://www.msn.com")!

Thanks!

ReveelTeam avatar Jul 23 '18 09:07 ReveelTeam

BTW, it works only for hosts with www. For example, for "https://msn.com" it doesn't work

erychagov avatar Jan 25 '19 11:01 erychagov

Related to this, I was hoping that the 'hostname' parameter within one of the convenience initializers is also exposed as a getter/setter property that can be dynamically changed (to avoid having to declare and init a new Reachability object just for monitoring a single URL).

I think the dependence on SCNetworkReachability will prevent this though

BTW, I'm also dependent on specifying my own port for https.

EdemAttiogbe avatar Apr 30 '19 21:04 EdemAttiogbe

So is there no way to use this framework if we want to test Reachability of an internal server; ex. "https://internalserver.company.com"? Or we just have to put "www" in front of it?

martheli avatar Jun 30 '19 23:06 martheli

I had issues too, but it turns out you just have to remove https://. Just try if you can ping a url first in Terminal, this doesn't work either with https:// in front of the url.

I don't know about the port numbers t.b.h.

Janneman84 avatar Jul 07 '21 07:07 Janneman84