Skip to content

Proxy Problem with WebSockets #419

@a-haroun

Description

@a-haroun
  • Bug exists Release Version 1.2.0 ( Master Branch)
    Hello everyone,

I want to use a proxy with websocket MQTT client but the programm does not take the http proxy into account and instead it tries to use a socks proxy. And even with a socks proxy i have the following error: java.net.SocketException: Malformed reply from SOCKS server : MqttException
Is this normal?

UPDATE:
We are able to use now an HTTP proxy by using a custom ConnectionFactory, but now we have an authentication problem even though i used an authenticator and the client is hanged!
This is the code:

class SocksSocketFactory extends SocketFactory {
	public Socket createSocket() throws IOException{
		final String username = "xxxxx";
		final String password = "xxxxx";
		
		Authenticator.setDefault(new Authenticator() {
			protected java.net.PasswordAuthentication getPasswordAuthentication() {
				return new PasswordAuthentication(username, password.toCharArray());
			}
		});
		System.setProperty("http.proxyHost", "proxy.enterprise.com");
		System.setProperty("http.proxyPort", "80");
		System.setProperty("http.proxyUser", username);
		System.setProperty("http.proxyPassword", password);
		
		InetSocketAddress httpProxy = new InetSocketAddress("proxy.enterprise.com", 80);
		Proxy proxy = new Proxy(Proxy.Type.HTTP, httpProxy);		
		Socket sock = new Socket(proxy);
		return sock;		
	}

Here is the network flow:
capture

Thank you in advance,
Amir

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions