simple-slack-api icon indicating copy to clipboard operation
simple-slack-api copied to clipboard

Reconnection process

Open jurepetrovic opened this issue 2 years ago • 4 comments

Hello,

when slack goes out of service, we sometimes get the following Null Pointer Exception: Stack Trace: java.lang.NullPointerException at com.ullink.slack.simpleslackapi.impl.SlackJSONSessionStatusParser.parse(SlackJSONSessionStatusParser.java:71) at com.ullink.slack.simpleslackapi.impl.SlackWebSocketSessionImpl.connectImpl(SlackWebSocketSessionImpl.java:389) at com.ullink.slack.simpleslackapi.impl.SlackWebSocketSessionImpl.connect(SlackWebSocketSessionImpl.java:348)

Has anyone any idea how to do reconnection attempt properly here?

I looked here, but if slack service goes down, we don't get goodbye message. https://github.com/Itiviti/simple-slack-api/issues/269

Thanks, Jure

jurepetrovic avatar Sep 27 '22 10:09 jurepetrovic

This error seems to be due to the RTM change deprecating the previous behavior of rtm.start and the new behavior not being supported by this library at the moment

ConnorLinfoot avatar Sep 27 '22 22:09 ConnorLinfoot

I used try/catch and then slack session builder to create autoreconnect SlackSession. It solves the problem where the client loses connection, but not when server drops.

@ConnorLinfoot How would you go about changing this behaviour? Where is rtm.start used? What was the change on RTM?

I got used to simple-slack-api, otherwise works fine for me and is lightweight. Would really like to solve this.

Thanks. Jure

jurepetrovic avatar Sep 28 '22 20:09 jurepetrovic

I used try/catch and then slack session builder to create autoreconnect SlackSession. It solves the problem where the client loses connection, but not when server drops.

@ConnorLinfoot How would you go about changing this behaviour? Where is rtm.start used? What was the change on RTM?

I got used to simple-slack-api, otherwise works fine for me and is lightweight. Would really like to solve this.

Thanks. Jure

Personally, I moved to using the official slack java client, I did originally try updating this client but upon realizing master seemed to be half updated to the new socket mode system instead of RTM I chose to leave it. Depending on your use case it may be better to also adopt the official client, as its more likely to stay up to date and have more support around it (although the documentation is a bit lacking in my opinion)

ConnorLinfoot avatar Sep 28 '22 23:09 ConnorLinfoot

Personally, I moved to using the official slack java client

Currently in the process of doing the same. I tried to use the current state of master yesterday, after having updated my app to the new way of interacting with the API (configuring scopes, adding an app token, configuring events to be sent to, reinstalling my app into my workspace...) but stumbled upon several problems:

  1. the ping/pong API does not work anymore, so the bot keeps disconnecting / reconnecting to Slack, I shunted the test in the WebSocket API class so that it stays connected (probably not the expected way of fixing things)
  2. the JSON payload received when an event occurs is not into the same format as the one expected earlier, we now need to object.get("payload").get("event") to find it back
  3. we now have to acknowledge every events received, which is not done here, so Slack keeps resending the events because of timeout

pmauduit avatar Sep 29 '22 08:09 pmauduit