okhttp 2.7.5 是否有代理失败?

Does okhttp 2.7.5 have proxy fall through?

我从 okhttp 2.7.5 移动到 3.10.0,当我在我的代理不是 valid/accessible 且系统属性 -Dhttp.proxyHost-Dhttp.proxyPort 的 VPN 上时设置后,客户端请求因连接超时而失败。在 2.7.5 上,即使设置了这些系统属性,如果我在这些值无效的网络上,它仍然有效。我的猜测是,如果无法访问代理,客户端将失败以在没有代理的情况下尝试请求。

这是预期的吗?

此行为在 OkHttp 3.5 中发生了变化。来自 changelog:

  • OkHttp no longer attempts a direct connection if the system's HTTP proxy fails. This behavior was surprising because OkHttp was disregarding the user's specified configuration. If you need to customize proxy fallback behavior, implement your own java.net.ProxySelector.