Reputation:
I need to read tweets according to certain hashtag filters, so I tried out Twitter's streaming api with the java hbc client. As a start, I tried to run the sample code provided with the project in order to get an idea on how it works.
So I :
BUT everytime I run hbc-example with maven I always seem to get :
(...)
[hosebird-client-io-thread-0] INFO com.twitter.hbc.httpclient.ClientBase - hoseb
ird-client-0 Establishing a connection
[hosebird-client-io-thread-0] WARN com.twitter.hbc.httpclient.ClientBase - hoseb
ird-client-0 IOException caught when establishing connection to https://stream.t
witter.com/1.1/statuses/filter.json?delimited=length&stall_warnings=true
[hosebird-client-io-thread-0] WARN com.twitter.hbc.httpclient.ClientBase - hoseb
ird-client-0 failed to establish connection properly
[hosebird-client-io-thread-0] INFO com.twitter.hbc.httpclient.ClientBase - hoseb
ird-client-0 Done processing, preparing to close connection
[hosebird-client-io-thread-0] INFO com.twitter.hbc.httpclient.ClientBase - hoseb
ird-client-0 Establishing a connection
[hosebird-client-io-thread-0] WARN com.twitter.hbc.httpclient.ClientBase - hoseb
ird-client-0 IOException caught when establishing connection to https://stream.t
witter.com/1.1/statuses/filter.json?delimited=length&stall_warnings=true
[hosebird-client-io-thread-0] WARN com.twitter.hbc.httpclient.ClientBase - hoseb
ird-client-0 failed to establish connection properly
[hosebird-client-io-thread-0] INFO com.twitter.hbc.httpclient.ClientBase - hoseb
ird-client-0 Done processing, preparing to close connection
[hosebird-client-io-thread-0] INFO com.twitter.hbc.httpclient.ClientBase - hoseb
ird-client-0 Establishing a connection
[hosebird-client-io-thread-0] WARN com.twitter.hbc.httpclient.ClientBase - hoseb
ird-client-0 IOException caught when establishing connection to https://stream.t
witter.com/1.1/statuses/filter.json?delimited=length&stall_warnings=true
(...)
This also happens when I run the hbc-example with the FilterStreamSample class as the class with the "main" function
Looking at the hbc-core sources, the exception seems to be thrown by the Connection object's connect(HttpUriRequest request) function (See : hbc-master/src/main/java/com/twitter/hbc/httpclient/Connection)
The Apache documentation for httpclient's exceptions doesn't give much of a clue as how to handle this error and I was wondering if there's something I'm missing here, a change at Twitter's streaming API that prevents my code from running, anything...
Thank you for any help or advice whatsoever!
Ps 1 : Just for the info, connect(HttpUriRequest request) is
Ps 2 : My problem could be similar to this yet-unsolved one : /questions/26363005/twitter-streaming-w-status-code-401
Upvotes: 2
Views: 1945
Reputation: 520
I am giving the answer too late, but might be useful for others. Actually this problems seems to come due to lack of configuration for proxy host and port if your network is configured to use with any kind of proxy. if some how you can browse through the codes and set the proxy host and port of your network, this problem will get resolved.
P.S : I found twitter streaming api very simple and easy to use, but don't forget to configure the proxy settings if you are using some network configured with proxy like workplace etc.
_configurationBuilder is type of twitter4j.conf.ConfigurationBuilder _configurationBuilder.setHttpProxyHost("you proxy host"); _configurationBuilder.setHttpProxyPort(your proxy port no);
if you miss it you will be getting some twitterException while listening to the message and will not get any information while googling also.
Upvotes: 4