首页 > 解决方案 > 如何使用 Pharo 获取 Twitter 提要?

问题描述

由于 Twitter 改变了他们的网站设计,我无法使用内置的 Zinc 类从任何帐户获取一组推文。它抛出一个错误,上面写着:ConnectionClosed: Connection closed while waiting for data

我正在使用Pharo 5,我不知道如何调整 ZnClient 设置以保持连接打开或以获取数据为目的。

testTwitter
    | client |
    self ensureSocketStreamFactory.
    self isNativeSSLPluginPresent ifFalse: [ ^ self ]. 
    (client := ZnClient new) 
        get: 'https://www.twitter.com/pharoproject'.
    self assert: client isSuccess.
    self assert: (client contents includesSubstring: 'Twitter').
    client close

那是我进行的测试,它永远不会通过,并引发上述错误。这里缺少什么?我使用 open-uri、openssl 和 Nokogiri 做了一个 Ruby 脚本,它可以很好地获取推文。也许这是 SSL 连接本身的问题?

标签: ssltwitterurismalltalkpharo

解决方案


The issue here is quite easy to answer, but you won't like it. Your issue is connected to the fact that the Twitter has deprecated support for TLS 1.0, TLS 1.1 on July 15/2019. Your pharo is using the deprecated TLS to connect. That is the reason why you are getting the timeout.

The solution?

You have to compile the new SSL/TLS support yourself which is not an easy task to do. You have to compile in at least TLS 1.2 to be able to connect again. There is lack of Pharo documentation how to compile support for new libraries. My guess is that you are using TLS 1.0 (see a note below) - since Pharo 6.1 (so your Pharo 5.x will have same or older libraries) has libgit2.so compiled against libssl.so.1.0.0 (which has dependency libcurl-gnutls.so.4) - If you update the libraries you can see that those support >= TLS 1.2.

Note:

This is connected to the issue which I have posted some time ago. Nobody upvoted it or answered so it got automatically deleted - you can vote to undelete it: https://stackoverflow.com/questions/51399321/getting-error-when-adding-ossubprocess-to-my-pharo-6-1-on-centos-7-4x (see the bottom of the post for the question). I don't have an answer for that as I have dedicated time to my Smalltalk/X project.


推荐阅读