【问题标题】:twitter hosebird client not working推特软管鸟客户端不工作
【发布时间】:2013-09-03 13:18:38
【问题描述】:

我正在尝试通过 hbc-twitter4j-v3 获取推文。示例代码是:https://github.com/twitter/hbc/blob/master/hbc-example/src/main/java/com/twitter/hbc/example/Twitter4jSampleStreamExample.java 为了在代理上启用身份验证,我还为主机、端口和身份验证设置了系统属性。但它显示以下错误-

[main] INFO com.twitter.hbc.httpclient.BasicClient - 执行的新连接:hosebird-client-0,端点:/1.1/statuses/sample.json?delimited=length&stall_warnings=true [hosebird-client-io-thread-0] INFO com.twitter.hbc.httpclient.ClientBase-hosebird-client-0 建立连接 [main] INFO com.twitter.hbc.httpclient.BasicClient - 停止客户端:hosebird-client-0,端点:/1.1/statuses/sample.json?delimited=length&stall_warnings=true [main] INFO com.twitter.hbc.httpclient.ClientBase - 软管鸟客户端 0 退出事件 - 被用户停止:等待 5000 毫秒 [main] WARN com.twitter.hbc.httpclient.ClientBase-hosebird-client-0 客户端线程未能在 5000 毫秒内完成 [main] INFO com.twitter.hbc.httpclient.BasicClient - 成功停止客户端:hosebird-client-0,端点:/1.1/statuses/sample.json?delimited=length&stall_warnings=true [hosebird-client-io-thread-0] 警告 com.twitter.hbc.httpclient.ClientBase-hosebird-client-0 未知主机-stream.twitter.com [hosebird-client-io-thread-0] 警告 com.twitter.hbc.httpclient.ClientBase-hosebird-client-0 无法正确建立连接 [hosebird-client-io-thread-0] INFO com.twitter.hbc.httpclient.ClientBase -hosebird-client-0 完成处理,准备关闭连接 [hosebird-client-io-thread-0] INFO com.twitter.hbc.httpclient.ClientBase-hosebird-client-0 关闭 httpclient 连接管理器

有什么帮助吗?? 提前致谢

【问题讨论】:

    标签: java twitter twitter4j twitter-hbc


    【解决方案1】:

    希望我没有忽略某些事情,但在我看来就是这样......

    如果通过设置属性是指http.proxy* 的属性,我认为它不会起作用,因为软管鸟客户端在后台使用 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 中添加代理支持。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-16
      • 1970-01-01
      • 2011-05-06
      • 2011-09-10
      • 2015-03-04
      相关资源
      最近更新 更多