简体   繁体   中英

Can't hit REST endpoint when VPN is on

I have a very elementary knowledge of networks. Please ELI5

I have some Java code that hits a test REST endpoint (GET). https://postman-echo.com/get?foo1=bar1&foo2=bar2

When running my code in my local environment and I have my corporate VPN off I'm able to hit that endpoint without error.

When I turn on my corporate VPN I start getting odd errors, specifically javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake

What could possibly be causing my java code to break when connected to a VPN?

What's even weirder is when I enter the endpoint in my browser while the VPN is on, I'm able to hit the endpoint as everything is normal.

OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
                  .url("https://postman-echo.com/get?foo1=bar1&foo2=bar2")
                  .build();

try (Response response = client.newCall(request).execute()) {
    return response.body().string();
}

EDIT

I have access to two proxies, the one used in my browser generated a 400 error and the other one works in my code. Why is a proxy required when using a VPN and what would differ between my 2 proxies, why would one generate a 400 in my code and not the other?

I strongly believe you need to make a call via proxy as this is happening in a corporate network. This issue is not occurring in the browser because of browser uses VPN settings to make an HTTP/HTTPS call. Adding a proxy setting in the code would solve the problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM