I'm developing an application where devices can connect and interact with each other via common wi-fi network and for the purpose of file exchange I'm using GCDWebServer
.
Everything is working great when I use usual wi-fi network or devices are connected to hotspot network with 3rd party host. But I encounter a strange issue when one of devices with the launched app is actually a host of a Hotspot.
I have this code:
- (void)startStreamHLSServer
{
dispatch_async(dispatch_get_main_queue(), ^{
if (!_webServer.isRunning)
{
_webServer = [GCDWebServer new];
[_webServer addGETHandlerForBasePath:@"/" directoryPath:[_fileManager videosURL].path indexFilename:nil cacheAge:3600 allowRangeRequests:YES];
[_webServer startWithPort:1000 bonjourName:nil];
NSLog(@"URL: %@", _webServer.serverURL.absoluteString);
}
});
}
The problem is that serverURL is nil
. Which actually seems logical because I checked a function GCDWebServerGetPrimaryIPAddress
which is supposed to tell the address and this function is only looking for addresses in the en0
interface when Hotspot network is actually bridge100
.
So question is - Is there a "normal" way to make GCDWebServer work with bridge100
?
SECOND PART:
Although serverURL
is nil, method startWithPort
returns true
. So I thought maybe server is running, it just can not tell me its address. So I got device's address with my custom method (if you're interested, I can attach it here, but I'm 100% sure it gives a correct address) and tried to use it in order to "speak" with web server, but no luck with that - server doesn't respond. So maybe startWithPort
returns a false result after all.
Very interesting observation - when I change primaryInterface
to bridge100
in GCDWebServerGetPrimaryIPAddress
method, it fixes the issue. GCDWebServer
shows a correct address and it is definitely running since I can have an access to the device folder.
Any help would be appreciated!