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

Item may not be null

Open MedAliRachid opened this issue 7 years ago • 14 comments

hi everyone , i want to use Slack in my application ,i started to search in Slack documentation... , until finding this library ... i get this message when i try to create a SlackSession ..

SlackSession session = SlackSessionFactory.createWebSocketSlackSession(bot_auth_token); session.connect(); please help :)

MedAliRachid avatar Sep 05 '16 14:09 MedAliRachid

Hi,

Could you provide a stack trace of your issue?

Best regards,

Benoit

bcorne avatar Sep 05 '16 16:09 bcorne

Hi , i execute session.connect(); using a button this is a stack trace : 09-05 17:59:35.988 23662-23662/com.example.mohamedali.slackproject D/ViewRootImpl: ViewPostImeInputStage ACTION_DOWN 09-05 17:59:36.578 23662-23662/com.example.mohamedali.slackproject I/System.out: 17:59:36.576 [main] INFO c.u.s.s.i.SlackWebSocketSessionImpl - connecting to slack 09-05 17:59:36.618 23662-23662/com.example.mohamedali.slackproject I/Choreographer: Skipped 34 frames! The application may be doing too much work on its main thread. 09-05 17:59:36.628 23662-23662/com.example.mohamedali.slackproject D/SecWifiDisplayUtil: Metadata value : none 09-05 17:59:36.628 23662-23662/com.example.mohamedali.slackproject D/ViewRootImpl: Buffer Count from app info with ::-1 && -1 for :: com.example.mohamedali.slackproject from View :: -1 DBQ Enabled ::false false 09-05 17:59:36.668 23662-23662/com.example.mohamedali.slackproject D/SRIB_DCS: log_dcs ThreadedRenderer::initialize entered! `

MedAliRachid avatar Sep 05 '16 17:09 MedAliRachid

the message is showed when i catch the IOException

           try {
                    SlackSession session = SlackSessionFactory.createWebSocketSlackSession("xoxp-75776625489-75776625521-76401161350-14bb776fdvsdvsv");
                    session.connect();
                }
                catch(Exception e){
                    Toast.makeText(getApplicationContext(),"error :"+e.getMessage(),Toast.LENGTH_LONG).show();
                }

MedAliRachid avatar Sep 05 '16 17:09 MedAliRachid

Hi,

It doesn't look like a stack trace. Which version of the library are you using?

Best regards,

benoit

bcorne avatar Sep 06 '16 15:09 bcorne

Hi,

I'm using the version 0.5.1

MedAliRachid avatar Sep 07 '16 15:09 MedAliRachid

Hi @bcorne,

I seem to be having exactly the same issue with the library. I've tried using the 'master' as well as older commits from December.

No error actually occurs, so there isn't a stack trace that I can share. It just hangs indefinitely. The last item appearing in the logs before it hangs is "connecting to slack" (SlackWebSocketSessionImpl.java#connectImpl() - line 294).

I'm trying to connect in exactly the same way as @MedAliRachid

try {
    SlackSession session = SlackSessionFactory.createWebSocketSlackSession("valid-token");
    session.connect();
}

The code above was actually running fine last week with a really old version of the lib checked out last year. Pulling a newer version of the lib has resulted in this issue.

I'll try to debug a little more, and I'll update you if I find anything of interest. In the meantime, if you have any idea of what may be causing this, I'd be grateful for any pointers.

Cheers.

joeltoby avatar Jan 22 '17 21:01 joeltoby

It seems to be building of the HttpClientwhich is causing the issue.

In the SlackWebSocketSessionImpl.java#getHttpClient() method line 774, the proxyHost variable is null and so the HttpClient is constructed as follows (line 782):

client = HttpClientBuilder.create().build();

I haven't figured out why the builder is failing yet. I'm wondering if it could be the version of HttpClient I have (currently version 4.4)

joeltoby avatar Jan 23 '17 00:01 joeltoby

I might have found something here - My project is also using the latest version of google-http-clientwhich has HttpClient v4.0.1 as a dependency.

Because of that, Maven is reporting that 4.4 "is omitted for conflict with 4.0.1". So in other words, I have 4.0.1 but the library is built for 4.4.

joeltoby avatar Jan 23 '17 00:01 joeltoby

Good detective work :). To catch this kind of issue at build time, consider using the maven-enforcer-plugin with the dependencyConvergence or even the requireUpperBoundDeps rule.

Stephan202 avatar Jan 23 '17 05:01 Stephan202

Thanks for the tip @Stephan202. I'll give that a try.

joeltoby avatar Jan 23 '17 09:01 joeltoby

Hi @Stephan202 ,

Sorry to bother you again about this. I've just tried to resolve the issue using requireUpperBoundDeps to enforce usage of HttpClient 4.4. I've also ensured that my classpath has updated.

Using 4.4, I'm now getting another similar error which I can't seem to get to the bottom of. If you have any idea of what may be causing it I'd be grateful!

The HttpClient is now constructed successfully (client = HttpClientBuilder.create().build();) and my team and channel info is returned as expected. But when it tries to establish the websocket container slightly later on SlackWebSocketSessionImpl.java#establishWebsocketConnection - line 329 it just hangs (no stacktrace).

From debugging, it looks like it may be using an incorrect version of a dependency. javax.websocket-api was my first thought? javax.websocket-api is not a direct dependency of simple-slack-api though.

I have also ensured that httpcore and httpmime are now on v4.4 and that commons-logging and commons-codec are on my classpath.

I'm running Tomcat 8.52 if that's of any use.

Thanks in advance!

joeltoby avatar Jan 26 '17 13:01 joeltoby

So it looks like I've resolved it. tyrus-standalone-client was missing. I'm not sure exactly how this happened, but I suspect it was caused by trying not to use jitpack. I ran gradle install to generate the Maven POM, and I believe some dependencies were not included in the generated POM.

joeltoby avatar Jan 26 '17 16:01 joeltoby

I suspect it was caused by trying not to use jitpack

So your issue happened on the master branch version?

bcorne avatar Jan 26 '17 17:01 bcorne

Yes.

I just found this open bug: https://github.com/Ullink/simple-slack-api/issues/120. A probable cause I think.

joeltoby avatar Jan 26 '17 17:01 joeltoby