From ea96bac31ade4134f23c8760fe960a5916967c91 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Wed, 23 Dec 2020 14:48:20 -0600 Subject: [PATCH] Display failing ports when connection fails --- .../ViewControllers/StreamFrameViewController.m | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Limelight/ViewControllers/StreamFrameViewController.m b/Limelight/ViewControllers/StreamFrameViewController.m index 84b6b95..c6e2e09 100644 --- a/Limelight/ViewControllers/StreamFrameViewController.m +++ b/Limelight/ViewControllers/StreamFrameViewController.m @@ -365,8 +365,8 @@ - (void)connectionTerminated:(int)errorCode { Log(LOG_I, @"Connection terminated: %d", errorCode); - unsigned int portTestResults = LiTestClientConnectivity(CONN_TEST_SERVER, 443, - LiGetPortFlagsFromTerminationErrorCode(errorCode)); + unsigned int portFlags = LiGetPortFlagsFromTerminationErrorCode(errorCode); + unsigned int portTestResults = LiTestClientConnectivity(CONN_TEST_SERVER, 443, portFlags); dispatch_async(dispatch_get_main_queue(), ^{ // Allow the display to go to sleep now @@ -387,7 +387,12 @@ case ML_ERROR_NO_VIDEO_TRAFFIC: title = @"Connection Error"; - message = @"No video received from host. Check the host PC's firewall and port forwarding rules."; + message = @"No video received from host."; + if (portFlags != 0) { + char failingPorts[256]; + LiStringifyPortFlags(portFlags, "\n", failingPorts, sizeof(failingPorts)); + message = [message stringByAppendingString:[NSString stringWithFormat:@"\n\nCheck your firewall and port forwarding rules for port(s):\n%s", failingPorts]]; + } break; case ML_ERROR_NO_VIDEO_FRAME: @@ -439,6 +444,11 @@ [UIApplication sharedApplication].idleTimerDisabled = NO; NSString* message = [NSString stringWithFormat:@"%s failed with error %d", stageName, errorCode]; + if (portTestFlags != 0) { + char failingPorts[256]; + LiStringifyPortFlags(portTestFlags, "\n", failingPorts, sizeof(failingPorts)); + message = [message stringByAppendingString:[NSString stringWithFormat:@"\n\nCheck your firewall and port forwarding rules for port(s):\n%s", failingPorts]]; + } if (portTestResults != ML_TEST_RESULT_INCONCLUSIVE && portTestResults != 0) { message = [message stringByAppendingString:@"\n\nYour device's network connection is blocking Moonlight. Streaming may not work while connected to this network."]; }