Visitar URL original
SocketModeApp (JavaWebSocket) does not support proxy with username:password · Issue #792 · slackapi/java-slack-sdk · GitHub
Skip to content

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

Description

@doncorsean-private

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

Activity

  1. doncorsean-private commented on Jul 26, 2021

    @doncorsean-private
    Author

    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)
    
  2. filmaj commented on Jul 27, 2021

    @filmaj
    Contributor

    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.

  3. added
    bugM-T: confirmed bug report. Issues are confirmed when the reproduction steps are documented
    and removed on Jul 27, 2021
  4. self-assigned this
    on Jul 27, 2021
  5. added this to the 1.10.0 milestone on Aug 10, 2021
  6. changed the title [-]How to set proxy for SocketModeApp?[/-] [+]How to set proxy for SocketModeApp (JavaWebSocket)?[/+] on Aug 10, 2021
  7. modified the milestones: 1.10.0, 1.x on Aug 10, 2021
  8. seratch commented on Aug 10, 2021

    @seratch
    Contributor

    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.

  9. changed the title [-]How to set proxy for SocketModeApp (JavaWebSocket)?[/-] [+]SocketModeApp (JavaWebSocket) does not support proxy with username:password[/+] on Aug 16, 2021
  10. added
    dependenciesPull requests that update a dependency file
    and removed
    bugM-T: confirmed bug report. Issues are confirmed when the reproduction steps are documented
    on Aug 16, 2021
  11. doncorsean-private commented on Aug 19, 2021

    @doncorsean-private
    Author

    Thx for the guidance @seratch !

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions