クロムブラウザを使用してhttps://pushover.net/にアクセスできますが、同じWebサイトにアクセスしようとすると、javaを使用してapiに接続してデータを送信しようとします。プロキシ経由のhttp-post
が、これは私のコード
HttpClient httpClient = (HttpClient) HttpClientBuilder.create()/*.setProxy(proxy)*/.build();
HttpPost post = new HttpPost("https://api.pushover.net/1/messages.json");
List<NameValuePair> nvps = new ArrayList<NameValuePair>();
nvps.add(new BasicNameValuePair("token", apiToken));
nvps.add(new BasicNameValuePair("user", userKey));
nvps.add(new BasicNameValuePair("message", message));
post.setEntity(new UrlEncodedFormEntity(nvps, Charset.defaultCharset()));
//point A
HttpResponse deviceResponse = httpClient.execute(post);
//point B
それが指すようになっているが、その後B点に到達するために年齢をとり、それがないときは例外を提供します。 例外が org.apache.http.conn.HttpHostConnectExceptionです:api.pushover.net:443に(api.pushover.net/108.59.13.232]を接続に失敗しました:接続タイマーアウト:接続を
私が試してみました残り
HttpHost proxy = new HttpHost("url",9090,"https");
httpClient = (HttpClient) HttpClientBuilder.create().setProxy(proxy).build();
の上に以下のコードを使用してプロキシを使用すると、これは私に javax.net.ssl.SSLHandshakeExceptionを与える:リモートホストはハンドシェイク
の間の接続を閉じて、私はその後も
を追加してみましたAuthenticator.setDefault(
new Authenticator() {
@Override
public PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(
authUser, authPassword.toCharArray());
}
}
);
System.setProperty("http.proxyUser", authUser);
System.setProperty("http.proxyPassword", authPassword);
しかし、同じSSLHandshakeExceptionを返します。
私はキーストアを作成するのを見ましたが、それは自分のマシンでのみ動作します。私はコードで動作するものを望み、それぞれに手動の設定をせずに1000のマシンにこのアプリケーションをデプロイできるようにします。 。
いいですかいいですか?