EllanJiang/GameFramework · error · GameFrameworkException
Not supported service type
Error message
Not supported service type '{0}'. What it means
CreateNetworkChannel switches on the ServiceType enum and only supports Tcp and TcpWithSyncReceive in this codebase. Any other ServiceType value falls into the default case and throws this formatted error. It usually indicates an enum value from a newer/other version or an uninitialized field.
Solutions
- Use ServiceType.Tcp or ServiceType.TcpWithSyncReceive
- Add the missing case to the switch in CreateNetworkChannel if you extended ServiceType with your own channel implementation
- Validate the enum value before calling; guard against uninitialized/default enum fields
Example fix
// before var channel = networkManager.CreateNetworkChannel(name, ServiceType.Udp, helper); // after var channel = networkManager.CreateNetworkChannel(name, ServiceType.TcpWithSyncReceive, helper);
Defensive patterns
Strategy: validation
Validate before calling
if (serviceType != ServiceType.Tcp && serviceType != ServiceType.TcpWithSyncReceive)
throw new InvalidOperationException($"Unsupported ServiceType: {serviceType}");
var channel = networkManager.CreateNetworkChannel(name, serviceType, helper); Type guard
bool IsSupported(ServiceType t) => t == ServiceType.Tcp || t == ServiceType.TcpWithSyncReceive;
Try / catch
try { var channel = networkManager.CreateNetworkChannel(name, serviceType, helper); }
catch (GameFrameworkException ex) { Log.Error("Unsupported service type: {0}", ex.Message); } Prevention
- Enum.IsDefined check on values read from config
- Don't serialize raw enum numbers across versions
- Keep ServiceType usage in sync with the runtime's switch cases
When it happens
Trigger: Passing a ServiceType value not handled by the switch (e.g. a UDP value added in another fork), or a default(ServiceType)/0 value that maps to an unsupported enum member.
Common situations: Upgrading GameFramework while custom code uses an enum member from a different branch; serializing ServiceType to config and reading back an out-of-range number; forgetting which service types the runtime supports.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- You must connect first.
- Socket is not active.
- Packet is invalid.
- Serialized packet failure.
- Packet header is invalid.
AI-assisted analysis of EllanJiang/GameFramework@d0c010b051 (2026-09-15).
Data as JSON: /api/errors/25cd6c2ffa2001e4.
Report an issue: GitHub.
Appendix: source
Thrown at GameFramework/Network/NetworkManager.cs:254
if (HasNetworkChannel(name))
{
throw new GameFrameworkException(Utility.Text.Format("Already exist network channel '{0}'.", name ?? string.Empty));
}
NetworkChannelBase networkChannel = null;
switch (serviceType)
{
case ServiceType.Tcp:
networkChannel = new TcpNetworkChannel(name, networkChannelHelper);
break;
case ServiceType.TcpWithSyncReceive:
networkChannel = new TcpWithSyncReceiveNetworkChannel(name, networkChannelHelper);
break;
default:
throw new GameFrameworkException(Utility.Text.Format("Not supported service type '{0}'.", serviceType));
}
networkChannel.NetworkChannelConnected += OnNetworkChannelConnected;
networkChannel.NetworkChannelClosed += OnNetworkChannelClosed;
networkChannel.NetworkChannelMissHeartBeat += OnNetworkChannelMissHeartBeat;
networkChannel.NetworkChannelError += OnNetworkChannelError;
networkChannel.NetworkChannelCustomError += OnNetworkChannelCustomError;
m_NetworkChannels.Add(name, networkChannel);
return networkChannel;
}
/// <summary>
/// 销毁网络频道。
/// </summary>
/// <param name="name">网络频道名称。</param>
/// <returns>是否销毁网络频道成功。</returns>
public bool DestroyNetworkChannel(string name)
{View on GitHub (pinned to d0c010b051)