下面是我的java代码:
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.connectors.twitter.TwitterSource;
import java.util.Properties;
public class FilterEnglishWords {
public static void main(String[] args) throws Exception {
final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
Properties props = new Properties();
props.setProperty(TwitterSource.CONSUMER_KEY, "xxx");
props.setProperty(TwitterSource.CONSUMER_SECRET, "xxx");
props.setProperty(TwitterSource.TOKEN, "xxx");
props.setProperty(TwitterSource.TOKEN_SECRET, "xxx");
env.addSource(new TwitterSource(props))
.print();
env.execute();
}
}
当我运行应用程序时,我得到以下错误。
WARN com.twitter.hbc.httpclient.ClientBase - flink-twitter-source failed to establish connection properly
INFO com.twitter.hbc.httpclient.ClientBase - flink-twitter-source Done processing, preparing to close connection
INFO com.twitter.hbc.httpclient.ClientBase - flink-twitter-source Establishing a connection
WARN com.twitter.hbc.httpclient.ClientBase - flink-twitter-source IOException caught when establishing connection to https://stream.twitter.com/1.1/statuses/sample.json
你知道这会是什么,怎么解决吗?
1条答案
按热度按时间k3bvogb11#
这是因为连接问题。我工作的那家公司已经封锁了通过终端的网络访问,而终端阻止了连接twitter的程序。
通过不同的网络连接解决了这个问题。