Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SocketModeApp (JavaWebSocket) does not support proxy with username:password #792

Open
doncorsean opened this issue Jul 26, 2021 · 4 comments
Assignees
Labels
dependencies Pull requests that update a dependency file project:slack-api-client project:slack-api-client
Milestone

Comments

@doncorsean
Copy link

doncorsean commented Jul 26, 2021

How do you configure proxy for Bolt Java SDK?

Able to set url using below but getting auth error

SlackConfig config = new SlackConfig();
    config.setProxyUrl("http://myproxy");

    Slack slack = Slack.getInstance(config);
    
    SocketModeClient client = slack.socketMode(appToken, SocketModeClient.Backend.JavaWebSocket);

    SocketModeApp socketModeApp = new SocketModeApp(
        client,
        app
    );
    socketModeApp.start();

The Slack SDK version

[INFO] +- com.slack.api:bolt:jar:1.9.0:compile
[INFO] | +- com.slack.api:slack-api-model:jar:1.9.0:compile
[INFO] | +- com.slack.api:slack-api-client:jar:1.9.0:compile
[INFO] | - com.slack.api:slack-app-backend:jar:1.9.0:compile
[INFO] +- com.slack.api:bolt-servlet:jar:1.9.0:compile
[INFO] +- com.slack.api:bolt-jetty:jar:1.9.0:compile
[INFO] +- com.slack.api:bolt-socket-mode:jar:1.9.0:compile

Java Runtime version

java version "1.8.0_271"
Java(TM) SE Runtime Environment (build 1.8.0_271-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.271-b09, mixed mode)

OS info

ProductName: Mac OS X
ProductVersion: 10.15.7
BuildVersion: 19H1217
Darwin Kernel Version 19.6.0: Thu May 6 00:48:39 PDT 2021; root:xnu-6153.141.33~1/RELEASE_X86_64

Expected result:

Connected to slack API

Actual result:

Failed to call auth.test API (error: Failed to authenticate with proxy)
java.io.IOException: Failed to authenticate with proxy

@doncorsean
Copy link
Author

doncorsean commented Jul 26, 2021

If I specify user:pass in url I get the following

11:14:47.879 [main] DEBUG c.s.api.socket_mode.SocketModeClient - The SocketMode client's going to use an HTTP proxy: http://user:pass@proxy:port
Exception in thread "main" java.lang.NullPointerException
	at com.slack.api.util.http.ProxyUrlUtil.setProxyAuthorizationHeader(ProxyUrlUtil.java:66)
	at com.slack.api.socket_mode.impl.SocketModeClientJavaWSImpl$UnderlyingWebSocketSession.<init>(SocketModeClientJavaWSImpl.java:230)
	at com.slack.api.socket_mode.impl.SocketModeClientJavaWSImpl$UnderlyingWebSocketSession.<init>(SocketModeClientJavaWSImpl.java:212)
	at com.slack.api.socket_mode.impl.SocketModeClientJavaWSImpl.<init>(SocketModeClientJavaWSImpl.java:114)
	at com.slack.api.socket_mode.impl.SocketModeClientJavaWSImpl.<init>(SocketModeClientJavaWSImpl.java:79)
	at com.slack.api.socket_mode.impl.SocketModeClientJavaWSImpl.<init>(SocketModeClientJavaWSImpl.java:70)
	at com.slack.api.Slack.socketMode(Slack.java:154)
	at App.main(App.java:52)

@filmaj
Copy link
Contributor

filmaj commented Jul 27, 2021

Hi @doncorsean ! I'm sorry you stumbled upon this issue. I am new to the project but let me see if I can help you at least find a workaround for this problem.

We do have some tests covering this code path (see the AuthProxyUserPasswordTest.java test suite) - but it seems like we have ignored / commented out one test that instantiates the SocketModeClient in the same way that you do (by passing it a JavaWebSocket Backend).

That said, the tests that don't explicitly specify a Backend (and, from the looks of the code, executes with the "Tyrus" Backend) seem to pass. So perhaps you can try that? Something like this:

SocketModeClient client = slack.socketMode(appToken);

... instead of:

SocketModeClient client = slack.socketMode(appToken, SocketModeClient.Backend.JavaWebSocket);

I hope this can help - and if not, I apologize in advance, I'm the new guy around these parts 😄 , and I can get help from someone more experienced with this project.

@filmaj filmaj added bug M-T: confirmed bug report. Issues are confirmed when the reproduction steps are documented project:slack-api-client project:slack-api-client and removed untriaged labels Jul 27, 2021
@filmaj filmaj self-assigned this Jul 27, 2021
@seratch seratch added this to the 1.10.0 milestone Aug 10, 2021
@seratch seratch changed the title How to set proxy for SocketModeApp? How to set proxy for SocketModeApp (JavaWebSocket)? Aug 10, 2021
@seratch seratch modified the milestones: 1.10.0, 1.x Aug 10, 2021
@seratch
Copy link
Member

seratch commented Aug 10, 2021

Hi @doncorsean, I tried to resolve this issue but I found that Java-WebSocket library does not support HTTP proxy with user / password as of today. Consider using Tyrus backend for now.

seratch added a commit to seratch/java-slack-sdk that referenced this issue Aug 11, 2021
seratch added a commit that referenced this issue Aug 11, 2021
* Improve the error caused in the #792 scenario

* Fix the test
@seratch seratch changed the title How to set proxy for SocketModeApp (JavaWebSocket)? SocketModeApp (JavaWebSocket) does not support proxy with username:password Aug 16, 2021
@seratch seratch added dependencies Pull requests that update a dependency file and removed bug M-T: confirmed bug report. Issues are confirmed when the reproduction steps are documented labels Aug 16, 2021
@doncorsean
Copy link
Author

Thx for the guidance @seratch !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file project:slack-api-client project:slack-api-client
Projects
None yet
Development

No branches or pull requests

3 participants