@@ -1144,7 +1144,7 @@ private bool ProcessEvent()
11441144 // means a clean disconnect that doesn't require logging.
11451145 if ( ! m_Driver . Listening && m_ServerClientId == default )
11461146 {
1147- Debug . LogError ( "Failed to connect to server." ) ;
1147+ LogClientConnectionFailureMessage ( ) ;
11481148 }
11491149
11501150 // Set the disconnect event error code
@@ -1172,6 +1172,40 @@ private bool ProcessEvent()
11721172 return false ;
11731173 }
11741174
1175+ private void LogClientConnectionFailureMessage ( )
1176+ {
1177+ if ( OnCurrentTopology ( ) == NetworkTopologyTypes . ClientServer )
1178+ {
1179+ var reasons = new List < string > { "Server/host is not running." } ;
1180+
1181+ if ( m_ProtocolType == ProtocolType . RelayUnityTransport && ! m_UseWebSockets )
1182+ {
1183+ reasons . Add ( "Relay port might be blocked on your network. Try using WebSockets." ) ;
1184+ if ( m_RelayServerData . IsSecure != 0 )
1185+ {
1186+ reasons . Add ( "DTLS might be blocked on your network. Try using UDP or WebSockets." ) ;
1187+ }
1188+ }
1189+ else if ( m_ProtocolType != ProtocolType . RelayUnityTransport )
1190+ {
1191+ reasons . Add ( $ "Server/host might not be reachable. Try \" ping { ConnectionData . Address } \" in a terminal.") ;
1192+ reasons . Add ( "The firewall on the server/host might be blocking the connection attempts." ) ;
1193+ if ( m_UseEncryption && ! m_UseWebSockets )
1194+ {
1195+ reasons . Add ( "DTLS might be blocked on your network. Try using WebSockets." ) ;
1196+ }
1197+ }
1198+
1199+ const string prefix = "\n \t - " ;
1200+ Debug . LogError ( "Failed to connect to server. Possible reasons:" + prefix + string . Join ( prefix , reasons ) ) ;
1201+ }
1202+ else
1203+ {
1204+ // If using DA the SDK should have logged an actual useful error.
1205+ Debug . LogError ( "Failed to connect to server." ) ;
1206+ }
1207+ }
1208+
11751209 /// <summary>
11761210 /// Handles accepting new connections and processing transport events.
11771211 /// </summary>
0 commit comments