error: RPC failed; HTTP 400 curl 22 The requested URL returned error: 400

1. 报错信息

bash 复制代码
Enumerating objects: 10, done.
Counting objects: 100% (10/10), done.
Delta compression using up to 8 threads
Compressing objects: 100% (8/8), done.
error: RPC failed; HTTP 400 curl 22 The requested URL returned error: 400
send-pack: unexpected disconnect while reading sideband packet
Writing objects: 100% (8/8), 1.18 MiB | 1.11 MiB/s, done.
Total 8 (delta 0), reused 0 (delta 0), pack-reused 0
fatal: the remote end hung

2. 解决

问了Qwen等LLM,没用,还是stackoverflow

根据:

执行以下操作:

bash 复制代码
# 方法1 把要push的内容分多次push,先回退,再分多次提交

# 方法2,临时修改 buffer size,提交完再改回去,防止吃内存
git config http.postBuffer 524288000
git pull && git push
git config --unset http.postBuffer

3. 原因探索

不一定是网络原因,而是 buffer size的问题

bash 复制代码
# 查看日志中关于http传输的信息
> GIT_CURL_VERBOSE=1 GIT_TRACE=1 git push 2>&1 | grep -A 10 "HTTP"
09:17:04.433505 http.c:701              == Info: CONNECT tunnel: HTTP/1.1 negotiated
09:17:04.433509 http.c:701              == Info: allocate connect buffer
 # 分配缓存
09:17:04.433515 http.c:701              == Info: Establish HTTP proxy tunnel to github.com:443
09:17:04.433557 http.c:648              => Send header, 0000000127 bytes (0x0000007f)
09:17:04.433564 http.c:660              => Send header: CONNECT github.com:443 HTTP/1.1
09:17:04.433567 http.c:660              => Send header: Host: github.com:443
09:17:04.433570 http.c:660              => Send header: User-Agent: git/2.39.2 (Apple Git-143)
09:17:04.433573 http.c:660              => Send header: Proxy-Connection: Keep-Alive
09:17:04.433575 http.c:660              => Send header:
09:17:04.433753 http.c:648              <= Recv header, 0000000037 bytes (0x00000025)
09:17:04.433761 http.c:660              <= Recv header: HTTP/1.1 200 Connection established
09:17:04.433775 http.c:648              <= Recv header, 0000000002 bytes (0x00000002)
09:17:04.433778 http.c:660              <= Recv header:
09:17:04.433783 http.c:701              == Info: CONNECT phase completed
09:17:04.433787 http.c:701              == Info: CONNECT tunnel established, response 200
09:17:04.433840 http.c:701              == Info: ALPN: curl offers h2,http/1.1
09:17:04.433996 http.c:701              == Info: (304) (OUT), TLS handshake, Client hello (1):
09:17:04.441583 http.c:701              == Info:  CAfile: /etc/ssl/cert.pem
09:17:04.441600 http.c:701              == Info:  CApath: none
09:17:05.517635 http.c:701              == Info: (304) (IN), TLS handshake, Server hello (2):
09:17:05.517918 http.c:701              == Info: (304) (IN), TLS handshake, Unknown (8):
--
09:17:05.521669 http.c:701              == Info: using HTTP/2
09:17:05.521703 http.c:701              == Info: [HTTP/2] [1] OPENED stream for https://github.com/XXX/XXX.git/info/refs?service=git-receive-pack
09:17:05.521708 http.c:701              == Info: [HTTP/2] [1] [:method: GET]
09:17:05.521710 http.c:701              == Info: [HTTP/2] [1] [:scheme: https]
09:17:05.521713 http.c:701              == Info: [HTTP/2] [1] [:authority: github.com]
09:17:05.521715 http.c:701              == Info: [HTTP/2] [1] [:path: /XXXX/XXXX.git/info/refs?service=git-receive-pack]
09:17:05.521718 http.c:701              == Info: [HTTP/2] [1] [user-agent: git/2.39.2 (Apple Git-143)]
09:17:05.521721 http.c:701              == Info: [HTTP/2] [1] [accept: */*]
09:17:05.521723 http.c:701              == Info: [HTTP/2] [1] [accept-encoding: deflate, gzip]
09:17:05.521726 http.c:701              == Info: [HTTP/2] [1] [pragma: no-cache]  
# 这里显示 no_cache 所以真的是缓存不够了????
09:17:05.521751 http.c:648              => Send header, 0000000198 bytes (0x000000c6)
09:17:05.521756 http.c:660              => Send header: GET /xxx/xxx.git/info/refs?service=git-receive-pack HTTP/2
09:17:05.521759 http.c:660              => Send header: Host: github.com
09:17:05.521761 http.c:660              => Send header: User-Agent: git/2.39.2 (Apple Git-143)
09:17:05.521764 http.c:660              => Send header: Accept: */*
09:17:05.521767 http.c:660              => Send header: Accept-Encoding: deflate, gzip
09:17:05.521769 http.c:660              => Send header: Pragma: no-cache
09:17:05.521771 http.c:660              => Send header:
09:17:05.521781 http.c:701              == Info: Request completely sent off
09:17:05.898901 http.c:648              <= Recv header, 0000000013 bytes (0x0000000d)
09:17:05.898912 http.c:660              <= Recv header: HTTP/2 401
09:17:05.898919 http.c:648              <= Recv header, 0000000026 bytes (0x0000001a)
09:17:05.898922 http.c:660              <= Recv header: server: GitHub-Babel/3.0
09:17:05.898927 http.c:648              <= Recv header, 0000000054 bytes (0x00000036)
09:17:05.898929 http.c:660              <= Recv header: content-security-policy: default-src 'none'; sandbox
09:17:05.898934 http.c:648              <= Recv header, 0000000041 bytes (0x00000029)
09:17:05.898936 http.c:660              <= Recv header: content-type: text/plain; charset=UTF-8
09:17:05.898940 http.c:648              <= Recv header, 0000000040 bytes (0x00000028)
09:17:05.898943 http.c:660              <= Recv header: www-authenticate: Basic realm="GitHub"
09:17:05.898958 http.c:648              <= Recv header, 0000000020 bytes (0x00000014)
09:17:05.898966 http.c:660              <= Recv header: content-length: 21
相关推荐
wangl_9215 小时前
Modbus RTU 与 Modbus TCP 深入指南-决策树与选型建议
网络·网络协议·tcp/ip·tcp·modbus·rtu
小船跨境16 小时前
ChatGPT助力高效网页数据抓取实战
人工智能·网络协议
JiaWen技术圈17 小时前
DTLS 基础
网络协议
m0_7381207218 小时前
ctfshow靶场SSRF部分——基础绕过到协议攻击解题思路与技巧(二)
python·网络协议·tcp/ip·安全·网络安全
Ogcloud_oversea19 小时前
SD-WAN 技术架构解析:控制平面与数据平面的解耦实践
运维·网络·网络协议·网络安全·信息与通信
树下水月19 小时前
HTTPS 站点请求 HTTP的API 接口服务报错的问题
网络协议·http·https
XiYang-DING19 小时前
【Java EE】 HTTP协议
java·http·java-ee
wangl_9219 小时前
Modbus RTU 与 Modbus TCP 深入指南-结束语
网络·网络协议·tcp/ip·tcp·modbus·rtu
皮卡祺q19 小时前
【Java网络编程核心-0】从OSI七层到TCP/IP模型深度解析(HTTP协议、TCP、UDP 、 IP协议)
网络·网络协议·tcp/ip·http·https·udp
DavidTaozhe20 小时前
美股api接口的WebSocket订阅如何实现自动重连
网络·websocket·网络协议