Address family not supported by protocol family: connect 解決方案

在springboot 使用okhttp請求其他服務的接口時,出現了Address family not supported by protocol family: connect這個異常, 後來把這一塊代碼單獨拎出去運行,是沒有任何問題的。

後來在StackOverflow上找到了一個可用的解決方案,具體爲什麼只在springboot環境下出現異常暫時還不太清楚。

解決方法
VM options 追加參數: -Djava.net.preferIPv4Stack=true

IDEA下的VM options設置方法如下,其他環境請自行百度。
在這裏插入圖片描述

轉自stackoverflow–Address family not supported by protocol family - SocketException on a specific computer

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章