Skip to content

Conversation

@artnaseef
Copy link

Support for NTLM proxies, using the Netty provider, did not appear to function due to the wrong header name being used on the second request from the client to the server in the handshake: Authorization should be Proxy-Authorization.

Attached is a pull request that fixes the problem against 1.8.10-SNAPSHOT.

Here's a snippet of code that shows how the NTLM proxy is configured.

/**
 * Configure the Async HTTP Client
 */
protected AsyncHttpClientConfig  getConfig () {
    AsyncHttpClientConfig.Builder configBuilder = new AsyncHttpClientConfig.Builder();

    if ( ntlmDomain != null ) {
        configBuilder
                .setRealm(new Realm.RealmBuilder()
                        .setPrincipal(this.username)
                        .setPassword(this.password)
                        .setNtlmDomain(this.ntlmDomain)
                        .setUsePreemptiveAuth(true)
                        .build());
    }

    return configBuilder.build();
}

public void execute () {
    AsyncHttpClientConfig config = this.getConfig();

    this.client = new AsyncHttpClient(config);

    try {
        Future<WebSocket> futureWebsocket;
        ProxyServer proxy = new ProxyServer(this.proxyProtocol, this.proxyServer, this.proxyServerPort,
                                            this.username, this.password);
        if ( ntlmDomain != null ) {
            proxy.setNtlmDomain(ntlmDomain);
        }

        futureWebsocket =
                this.client.prepareGet(this.wsUrl)
                        .setProxyServer(proxy)
                        .execute(new WebSocketUpgradeHandler.Builder().build());

        LOG.info("waiting for websocket connection");
        final WebSocket websocket = futureWebsocket.get();

        if ( websocket != null ) {
            LOG.info("received websocket connection");

            websocket.addWebSocketListener(new WebSocketTextListener() {
                @Override
                public void onMessage(String s) {
                    LOG.info("received response {}", s);
                    processAgentRequest(websocket, s);
                }

            ...
}

@slandelle slandelle added this to the 1.8.10 milestone Jun 3, 2014
@slandelle slandelle self-assigned this Jun 3, 2014
slandelle pushed a commit that referenced this pull request Jun 3, 2014
Support NTLM protocol with the proxy: fixed the header name for Proxy-Authorization
@slandelle slandelle merged commit 9a520e4 into AsyncHttpClient:1.8.x Jun 3, 2014
@slandelle
Copy link
Contributor

Thanks!
Will port on master.

slandelle pushed a commit that referenced this pull request Jun 3, 2014
@artnaseef
Copy link
Author

Awesome - thank you!

Do you have an ETA on the next 1.8.x release (1.8.10?)? It would be awesome to avoid keeping a fork for any length of time.

Oh, and thanks for this awesome project. We're using it for WebSockets behind proxies, and it's going great so far!

@jfarcand
Copy link
Contributor

jfarcand commented Jun 5, 2014

@artnaseef I can cut the release as soon as next week. @slandelle , what do you think?

@slandelle
Copy link
Contributor

Whenever you want.

2014-06-06 0:37 GMT+02:00 Jeanfrancois Arcand notifications@github.com:

@artnaseef https://github.com/artnaseef I can cut the release as soon
as next week. @slandelle https://github.com/slandelle , what do you
think?


Reply to this email directly or view it on GitHub
#563 (comment)
.

@artnaseef
Copy link
Author

@jfarcand - next week would be excellent! Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants