shadowsocks/shadowsocks-windows · error · NotSupportedException
Unknown forward proxy.
Error message
Unknown forward proxy.
What it means
Thrown as NotSupportedException when config.useProxy is true but config.proxyType does not match PROXY_SOCKS5 or PROXY_HTTP. Only those two forward-proxy types are implemented; any other value falls through the switch's default. It fires during remote connection setup, before a proxy endpoint is resolved.
Source
Thrown at shadowsocks-csharp/Controller/Service/TCPRelay.cs:675
EndPoint pluginEP = _controller.GetPluginLocalEndPointIfConfigured(_server);
if (pluginEP != null)
{
serverEP = pluginEP;
remote = new DirectConnect();
}
else if (_config.useProxy)
{
switch (_config.proxyType)
{
case ForwardProxyConfig.PROXY_SOCKS5:
remote = new Socks5Proxy();
break;
case ForwardProxyConfig.PROXY_HTTP:
remote = new HttpProxy();
break;
default:
throw new NotSupportedException("Unknown forward proxy.");
}
proxyEP = SocketUtil.GetEndPoint(_config.proxyServer, _config.proxyPort);
}
else
{
remote = new DirectConnect();
}
AsyncSession session = new AsyncSession(remote);
lock (_closeConnLock)
{
if (_closed)
{
remote.Close();
return;
}
_currentRemoteSession = session;
View on GitHub (pinned to 891d971682)
Solutions
- Set proxyType to one of the supported constants (PROXY_SOCKS5 or PROXY_HTTP), or disable useProxy.
- If you genuinely need a new proxy type, add a matching case + implementation before using it.
- Validate proxyType against the known set when loading config and reject invalid values early with a clear message.
Example fix
// before
default:
throw new NotSupportedException("Unknown forward proxy.");
// after: include the offending value
throw new NotSupportedException($"Unknown forward proxy type: {_config.proxyType}"); Defensive patterns
Strategy: validation
Validate before calling
// Validate proxy type when loading config
if (config.useProxy &&
config.proxyType != ForwardProxyConfig.PROXY_SOCKS5 &&
config.proxyType != ForwardProxyConfig.PROXY_HTTP)
{ /* reset useProxy or clamp to a known type */ } Type guard
bool IsValidProxyType(string t) =>
t == ForwardProxyConfig.PROXY_SOCKS5 || t == ForwardProxyConfig.PROXY_HTTP; Try / catch
try { /* connect via forward proxy */ }
catch (NotSupportedException ex) when (ex.Message.Contains("Unknown forward proxy"))
{ /* disable useProxy, inform user */ } Prevention
- Reject unknown proxyType at config load with a clear message.
- When adding a proxy type, add the switch case in the same change.
- Persist proxyType only through validated UI controls, not free text.
When it happens
Trigger: A future/unknown proxyType constant was introduced without adding a case; gui-config.json was hand-edited and proxyType set to an invalid or typo'd value; an enum-like field stored as a string/int that deserialized to an unexpected value.
Common situations: Editing the config file and entering a wrong proxy type string; code merge that adds a new proxy type but forgets the switch case; corrupt config yielding an out-of-range integer.
Related errors
- Port out of range
- Port can't be 8123
- Password can not be blank
- Server IP can not be blank
- Timeout is invalid, it should not exceed {0}
AI-assisted analysis of shadowsocks/shadowsocks-windows@891d971682 (2026-08-13).
Data as JSON: /api/errors/d0e746aab63947ee.
Report an issue: GitHub.