fix(executor): correctly disable http2 ALPN in Antigravity client to resolve connection reset errors
This commit is contained in:
@@ -83,7 +83,14 @@ func newAntigravityHTTPClient(ctx context.Context, cfg *config.Config, auth *cli
|
|||||||
if tr, ok := client.Transport.(*http.Transport); ok {
|
if tr, ok := client.Transport.(*http.Transport); ok {
|
||||||
trClone := tr.Clone()
|
trClone := tr.Clone()
|
||||||
trClone.ForceAttemptHTTP2 = false
|
trClone.ForceAttemptHTTP2 = false
|
||||||
|
// Also wiping TLSNextProto is good practice
|
||||||
trClone.TLSNextProto = make(map[string]func(authority string, c *tls.Conn) http.RoundTripper)
|
trClone.TLSNextProto = make(map[string]func(authority string, c *tls.Conn) http.RoundTripper)
|
||||||
|
// Crucial: The transport must actively advertise only http/1.1 in the ALPN handshake
|
||||||
|
if trClone.TLSClientConfig == nil {
|
||||||
|
trClone.TLSClientConfig = &tls.Config{}
|
||||||
|
}
|
||||||
|
trClone.TLSClientConfig.NextProtos = []string{"http/1.1"}
|
||||||
|
|
||||||
client.Transport = trClone
|
client.Transport = trClone
|
||||||
}
|
}
|
||||||
return client
|
return client
|
||||||
@@ -1038,7 +1045,7 @@ func FetchAntigravityModels(ctx context.Context, auth *cliproxyauth.Auth, cfg *c
|
|||||||
|
|
||||||
baseURLs := antigravityBaseURLFallbackOrder(auth)
|
baseURLs := antigravityBaseURLFallbackOrder(auth)
|
||||||
httpClient := newAntigravityHTTPClient(ctx, cfg, auth, 0)
|
httpClient := newAntigravityHTTPClient(ctx, cfg, auth, 0)
|
||||||
|
|
||||||
for idx, baseURL := range baseURLs {
|
for idx, baseURL := range baseURLs {
|
||||||
modelsURL := baseURL + antigravityModelsPath
|
modelsURL := baseURL + antigravityModelsPath
|
||||||
|
|
||||||
@@ -1075,6 +1082,7 @@ func FetchAntigravityModels(ctx context.Context, auth *cliproxyauth.Auth, cfg *c
|
|||||||
log.Debugf("antigravity executor: models request error on base url %s, retrying with fallback base url: %s", baseURL, baseURLs[idx+1])
|
log.Debugf("antigravity executor: models request error on base url %s, retrying with fallback base url: %s", baseURL, baseURLs[idx+1])
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
log.Errorf("antigravity executor: models request failed: %v", errDo)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1087,6 +1095,7 @@ func FetchAntigravityModels(ctx context.Context, auth *cliproxyauth.Auth, cfg *c
|
|||||||
log.Debugf("antigravity executor: models read error on base url %s, retrying with fallback base url: %s", baseURL, baseURLs[idx+1])
|
log.Debugf("antigravity executor: models read error on base url %s, retrying with fallback base url: %s", baseURL, baseURLs[idx+1])
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
log.Errorf("antigravity executor: models read body failed: %v", errRead)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if httpResp.StatusCode < http.StatusOK || httpResp.StatusCode >= http.StatusMultipleChoices {
|
if httpResp.StatusCode < http.StatusOK || httpResp.StatusCode >= http.StatusMultipleChoices {
|
||||||
@@ -1094,6 +1103,7 @@ func FetchAntigravityModels(ctx context.Context, auth *cliproxyauth.Auth, cfg *c
|
|||||||
log.Debugf("antigravity executor: models request rate limited on base url %s, retrying with fallback base url: %s", baseURL, baseURLs[idx+1])
|
log.Debugf("antigravity executor: models request rate limited on base url %s, retrying with fallback base url: %s", baseURL, baseURLs[idx+1])
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
log.Errorf("antigravity executor: models request error status %d: %s", httpResp.StatusCode, string(bodyBytes))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user