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
相关推荐
hoududubaba8 小时前
ORAN压缩之块浮点压缩
网络·网络协议
tryxr12 小时前
如何基于UDP实现可靠传输
网络·网络协议·udp·tcp
~央千澈~12 小时前
抖音弹幕游戏开发之第8集:pyautogui基础 - 模拟键盘操作·优雅草云桧·卓伊凡
网络·python·websocket·网络协议
桂花很香,旭很美13 小时前
[7天实战入门Go语言后端] Day 2:用 Go 写一个 HTTP 服务——net/http 入门
http·golang·xcode
3秒一个大18 小时前
JWT 登录:原理剖析与实战应用
前端·http·代码规范
yukai0800821 小时前
【203篇系列】041 Websocket Server
网络·websocket·网络协议
..过云雨1 天前
多路转接epoll+Reactor反应堆
网络·网络协议·计算机网络
橙露1 天前
计算机网络核心:HTTP/HTTPS 协议原理与抓包分析实战
计算机网络·http·https
小同志001 天前
⽹络原理-HTTP/HTTPS(一)
网络协议·http·https