SocketModeApp (JavaWebSocket) does not support proxy with username:password
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
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)
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.
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.
Thx for the guidance @seratch !