背景
鼓搗了一套新的方案,在命令行里想出國
,寫到了腳本函數里,這之后就遇到 git pull | push 都報錯(LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 60),於是開始排查問題
發現問題
git push
fatal: unable to access 'https://github.com/XXX/XXX.git/': LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to 127.0.0.1:8001
git pull
fatal: unable to access 'https://github.com/XXX/XXX.git/': LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to 127.0.0.1:8001
然后直接 github 也不行:
查看配置
因為不是新方案嘛,加了新的環境變量代理,就走不通,我的配置如下:
export http_proxy=http://127.0.0.1:8001;
export https_proxy=https://127.0.0.1:8001;
發現問題
根據報錯情況來看,是 8001 端口不通,但是梯子代理明明是 8001,再仔細一看,原來是粗心了,本地只代理了http=> 8001 ,沒有 https 代理,我的配置應該是將 https 的請求也通過 http://127.0.0.1:8001來代理出去,至此修改環境變量配置:
export https_proxy=http://127.0.0.1:8001;
解決問題且驗證
總結
- 除了仔細排查日志,還建議做回歸驗證,保證確實是某個 case 引起的問題。
- 理解代理的作用和使用場景
- 規范配置化信息格式,經常梳理,我把寫好的 shell 函數放到下面,大家可以拿來參考。
# 終端代理配置 開啟后每次打開終端都生效
function proxy {
if [[ $1 = "on" ]]; then
export http_proxy=http://127.0.0.1:8001
export https_proxy=http://127.0.0.1:8001
# 驗證當前 ip 信息
curl ifconfig.co
echo -e "已開啟代理" http_proxy=$http_proxy https_proxy=$https_proxy
elif [[ $1 = "off" ]]; then
unset http_proxy
unset https_proxy
git config --global --unset http.proxy
git config --global --unset https.proxy
echo -e "已關閉代理"
elif [[ $1 = "git" ]]; then
git config --global http.proxy 'https://127.0.0.1:8001'
git config --global https.proxy 'https://127.0.0.1:8001'
echo -e "已經開啟 git"
elif [[ $1 = "gitsock" ]]; then
git config --global http.proxy 'socks://localhost:1080'
git config --global https.proxy 'socks://localhost:1080'
echo -e "已經開啟 gitsock!"
else
echo -n "Usage: proxy [on|off|git] "
fi
}
參考 github issue https://github.com/libressl-portable/portable/issues/369