egametang/ET · error
http request fail: {link.Substring(0,link.IndexOf('?'))}\n{e
Error message
http request fail: {link.Substring(0,link.IndexOf('?'))}\n{e} What it means
Thrown by HttpClientHelper.Get as a catch-all wrapping any exception during an HTTP GET. It strips the query string from the URL for the message (everything before '?') and appends the inner exception. Note: if the URL contains no '?', link.IndexOf('?') returns -1, and link.Substring(0, -1) itself throws ArgumentOutOfRangeException, masking the real error.
Source
Thrown at Packages/cn.etetet.loader/Scripts/Loader/Share/HttpClientHelper.cs:27
{
public static async ETTask<string> Get(string link)
{
try
{
#if UNITY_WEBGL // 这里只能限制WEBGL, 因为NetClient Fiber会调用,如果改成UNITY会导致不是在主线程使用
UnityEngine.Networking.UnityWebRequest req = UnityEngine.Networking.UnityWebRequest.Get(link);
await req.SendWebRequest();
return req.downloadHandler.text;
#else
using HttpClient httpClient = new();
HttpResponseMessage response = await httpClient.GetAsync(link);
string result = await response.Content.ReadAsStringAsync();
return result;
#endif
}
catch (Exception e)
{
throw new Exception($"http request fail: {link.Substring(0,link.IndexOf('?'))}\n{e}");
}
}
}
}View on GitHub (pinned to 5cab01f7a8)
Solutions
- Verify the URL is reachable from the runtime environment (correct host, port, scheme, no firewall blocking).
- If the URL legitimately has no query string, note that the Substring(0, IndexOf('?')) in the catch will itself throw — patch HttpClientHelper.Get to use a safe index: link.Substring(0, link.IndexOf('?') >= 0 ? link.IndexOf('?') : link.Length).
- Check server logs and network connectivity (firewall rules, DNS resolution, TLS cert validity).
Example fix
// before
throw new Exception($"http request fail: {link.Substring(0,link.IndexOf('?'))}\n{e}");
// after: guard against missing '?'
int qIdx = link.IndexOf('?');
string safeUrl = qIdx >= 0 ? link.Substring(0, qIdx) : link;
throw new Exception($"http request fail: {safeUrl}\n{e}"); Defensive patterns
Strategy: try-catch
Validate before calling
// Validate URL before calling HttpClientHelper.Get
if (string.IsNullOrWhiteSpace(link) || !Uri.TryCreate(link, UriKind.Absolute, out _))
{
Log.Error($"Invalid URL for HttpClientHelper.Get: {link}");
return null;
} Try / catch
try { string result = await HttpClientHelper.Get(link); } catch (Exception e) { Log.Error($"HTTP GET failed for {link}: {e.Message}"); /* fallback or retry */ } Prevention
- Always validate URLs with Uri.TryCreate before passing to HttpClientHelper.Get.
- Be aware the catch block will itself throw if the URL has no '?' character — patch HttpClientHelper.Get to guard IndexOf.
- Implement retry-with-backoff for transient network failures rather than failing on first attempt.
When it happens
Trigger: Calling HttpClientHelper.Get with a URL that is unreachable, returns a non-success HTTP status, has DNS resolution failure, or has a network timeout. On WebGL builds, UnityWebRequest.SendWebRequest() failing (network error, CORS, invalid URL).
Common situations: Wrong server address or port in config. Server is down or behind a firewall. DNS not resolving in the build environment. URL missing '?' query separator causes a secondary Substring crash. SSL/TLS certificate issues on the target endpoint.
Related errors
- http request fail: {link.Substring(0,link.IndexOf('?'))}\n{e
- 请先在cmd中运行: netsh http add urlacl url=http://*:你的address中的端口/
- RouterManager dynamic http bind failed after 10 attempts.
- Only IPv4 addresses are supported
- default conn throw Exception! {channelId}
AI-assisted analysis of egametang/ET@5cab01f7a8 (2026-08-13).
Data as JSON: /api/errors/f4355244f1398e19.
Report an issue: GitHub.