2013-08-30 97 views
2

我想通過hbc-twitter4j-v3獲取推文。示例代碼是:https://github.com/twitter/hbc/blob/master/hbc-example/src/main/java/com/twitter/hbc/example/Twitter4jSampleStreamExample.java 爲了在代理上啓用身份驗證,我還爲主機,端口和身份驗證設置了系統屬性。但它顯示以下錯誤 -twitter hosebird客戶端不工作

 
[main] INFO com.twitter.hbc.httpclient.BasicClient - New connection executed: hosebird-client-0, endpoint: /1.1/statuses/sample.json?delimited=length&stall_warnings=true 
[hosebird-client-io-thread-0] INFO com.twitter.hbc.httpclient.ClientBase - hosebird-client-0 Establishing a connection 
[main] INFO com.twitter.hbc.httpclient.BasicClient - Stopping the client: hosebird-client-0, endpoint: /1.1/statuses/sample.json?delimited=length&stall_warnings=true 
[main] INFO com.twitter.hbc.httpclient.ClientBase - hosebird-client-0 exit event - Stopped by user: waiting for 5000 ms 
[main] WARN com.twitter.hbc.httpclient.ClientBase - hosebird-client-0 Client thread failed to finish in 5000 millis 
[main] INFO com.twitter.hbc.httpclient.BasicClient - Successfully stopped the client: hosebird-client-0, endpoint: /1.1/statuses/sample.json?delimited=length&stall_warnings=true 
[hosebird-client-io-thread-0] WARN com.twitter.hbc.httpclient.ClientBase - hosebird-client-0 Unknown host - stream.twitter.com 
[hosebird-client-io-thread-0] WARN com.twitter.hbc.httpclient.ClientBase - hosebird-client-0 failed to establish connection properly 
[hosebird-client-io-thread-0] INFO com.twitter.hbc.httpclient.ClientBase - hosebird-client-0 Done processing, preparing to close connection 
[hosebird-client-io-thread-0] INFO com.twitter.hbc.httpclient.ClientBase - hosebird-client-0 Shutting down httpclient connection manager 

任何幫助? 在此先感謝

回答

0

但願我沒有遺漏的東西,但這個是怎麼在我看來......

如果通過設置屬性你指的是那些http.proxy*,我不認爲它會工作作爲hosebird客戶端使用Apache的HTTP客戶端,但似乎沒有使用它們。

從粗略瀏覽代碼,特別是圍繞ClientBuilder,它看起來不像hbc支持代理配置 - 也許他們有一個很好的理由不要或不需要自己的功能,也許嘗試請求它?

它看起來像你可以得到HttpClient使用代理的方式之一是通過adding it to the HttpParams object,如:

HttpParams params = ... 
HttpHost proxy = new HttpHost(hostname, port); 
params.setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy); 

雖然HttpParams對象不暴露任何地方,你可能會爲了延長ClientBuilder到提供您的代理配置。如果您查看ClientBuilder#build()方法,您可以看到HttpParams對象正在設置的位置。祝你好運!

編輯:此外,此issue表示沒有計劃直接在hbc中添加代理支持。