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