diff --git a/src/main/java/com/opendxl/client/DxlClient.java b/src/main/java/com/opendxl/client/DxlClient.java index 4356f69..228393e 100644 --- a/src/main/java/com/opendxl/client/DxlClient.java +++ b/src/main/java/com/opendxl/client/DxlClient.java @@ -1370,8 +1370,15 @@ private synchronized void doConnect(final Map brokers) Authenticator.setDefault(new Authenticator() { @Override protected PasswordAuthentication getPasswordAuthentication() { - return new PasswordAuthentication( - getConfig().getProxyUserName(), getConfig().getProxyPassword()); + // Only use the proxy username and password in the config if the requesting host and port + // matches the proxy host address and port in the config + if (getRequestingHost().equalsIgnoreCase(getConfig().getProxyAddress()) + && getRequestingPort() == getConfig().getProxyPort()) { + return new PasswordAuthentication( + getConfig().getProxyUserName(), getConfig().getProxyPassword()); + } + + return null; } }); }