netchx/netch · error · MessageException
Invalid tcp type {server.FakeType}
Error message
Invalid tcp type {server.FakeType} What it means
When building V2Ray StreamSettings for a VMess/VLESS server whose TransferProtocol is 'tcp', the header obfuscation FakeType is only allowed to be 'none' or 'http'. The switch over server.FakeType handles those two cases and throws on the wildcard for anything else. The other entries in VMessGlobal.FakeTypes (srtp, utp, wechat-video, dtls, wireguard, gun, multi) are valid only for kcp/quic/grpc transports, not tcp.
Source
Thrown at Netch/Servers/V2ray/V2rayConfigUtils.cs:346
case "tcp":
streamSettings.tcpSettings = new TcpSettings
{
header = new
{
type = server.FakeType,
request = server.FakeType switch
{
"none" => null,
"http" => new
{
path = server.Path.SplitOrDefault(),
headers = new
{
Host = server.Host.SplitOrDefault()
}
},
_ => throw new MessageException($"Invalid tcp type {server.FakeType}")
}
}
};
break;
case "ws":
streamSettings.wsSettings = new WsSettings
{
path = server.Path.ValueOrDefault(),
headers = new
{
Host = server.Host.ValueOrDefault()
}
};
break;
case "kcp":View on GitHub (pinned to 9d99eb1c5a)
Solutions
- Set FakeType to 'none' or 'http' when TransferProtocol is tcp.
- If you need srtp/utp/wechat-video/dtls/wireguard obfuscation, switch TransferProtocol to kcp; for gun/multi use grpc.
- Re-import the vmess:// or vless:// link from a trusted source.
- Validate the (TransferProtocol, FakeType) pair in the server editor before saving the server.
Example fix
// before
request = server.FakeType switch
{
"none" => null,
"http" => new { path = server.Path.SplitOrDefault(), headers = new { Host = server.Host.SplitOrDefault() } },
_ => throw new MessageException($"Invalid tcp type {server.FakeType}")
};
// after - treat an unknown tcp FakeType as none instead of throwing
request = server.FakeType switch
{
"none" => null,
"http" => new { path = server.Path.SplitOrDefault(), headers = new { Host = server.Host.SplitOrDefault() } },
_ => null
}; Defensive patterns
Strategy: validation
Validate before calling
// Validate before building V2Ray config
static readonly HashSet<string> TcpFakeTypes = new() { "none", "http" };
if (server.TransferProtocol == "tcp" && !TcpFakeTypes.Contains(server.FakeType))
throw new MessageException($"tcp only supports FakeType none/http, got '{server.FakeType}'"); Type guard
bool IsValidTcpFakeType(string fakeType) => fakeType is "none" or "http";
bool IsValidPair(string protocol, string fakeType) => protocol switch
{
"tcp" => fakeType is "none" or "http",
"kcp" => fakeType is "none" or "srtp" or "utp" or "wechat-video" or "dtls" or "wireguard",
"grpc" => fakeType is "gun" or "multi",
_ => true
}; Try / catch
try { streamSettings = BuildStreamSettings(server); }
catch (MessageException ex) when (ex.Message.StartsWith("Invalid tcp type"))
{
MessageBoxX.Show("This server's header type is invalid for tcp. Set it to none or http.", LogLevel.ERROR);
} Prevention
- Constrain the FakeType combo box options based on the selected TransferProtocol in the server editor.
- Reject mismatched (net, headerType) pairs at import time in ParseUri.
- Keep the canonical allowed-pairs table (VMessGlobal.TransferProtocols / FakeTypes) as the single source of truth.
When it happens
Trigger: A VMess/VLESS server configured with TransferProtocol='tcp' and a FakeType that is not none/http (e.g. srtp, http copied from a kcp config). Importing a vmess:// link whose headerType field is incompatible with net=tcp; manually editing the server JSON to an invalid combination.
Common situations: Copy-pasting kcp obfuscation settings onto a tcp server; a malformed share link with headerType set for the wrong transport; an older client exporting headerType even when net is tcp; user conflating FakeType semantics across transports.
Related errors
- transfer protocol "{server.TransferProtocol}" not implemente
- The {0} port is in use.
- The {0} port is reserved by system.
- DNS format invalid
- AioDNS start failed.
AI-assisted analysis of netchx/netch@9d99eb1c5a (2026-08-13).
Data as JSON: /api/errors/7022fc90332c4848.
Report an issue: GitHub.