ckan datapusher /api/3/action/resource_show(由 <class 'socket.error'> 引起:[Errno 111] Connection

Posted

技术标签:

【中文标题】ckan datapusher /api/3/action/resource_show(由 <class \'socket.error\'> 引起:[Errno 111] Connection denied)错误【英文标题】:ckan datapusher /api/3/action/resource_show (Caused by <class 'socket.error'>: [Errno 111] Connection refused) errorckan datapusher /api/3/action/resource_show(由 <class 'socket.error'> 引起:[Errno 111] Connection denied)错误 【发布时间】:2017-02-01 11:17:04 【问题描述】:

我正在尝试安装 ckan 2.2.1 + pgsql 9.1 + solr 3.6 + rhel 6.6。

我设置了文件存储和数据存储插件。我尝试在 ckan web 中使用“上传到数据存储”菜单。然后我得到了这个错误。

2016-09-23 23:16:54,655 INFO  [ckan.lib.base]  /dataset/datastore/resource_data/7a82b5c2-d68c-4bed-b5c6-fcc460011455 render time 0.363 seconds
Job "push_to_datastore (trigger: RunTriggerNow, run = True, next run at: None)" raised an exception
Traceback (most recent call last):
  File "/usr/lib/ckan/default/lib/python2.7/site-packages/apscheduler/scheduler.py", line 512, in _run_job
    retval = job.func(*job.args, **job.kwargs)
  File "/usr/lib/ckan/default/src/ckan/datapusher/datapusher/jobs.py", line 300, in push_to_datastore
    resource = get_resource(resource_id, ckan_url, api_key)
  File "/usr/lib/ckan/default/src/ckan/datapusher/datapusher/jobs.py", line 250, in get_resource
    'Authorization': api_key
  File "/usr/lib/ckan/default/lib/python2.7/site-packages/requests/api.py", line 87, in post
    return request('post', url, data=data, **kwargs)
  File "/usr/lib/ckan/default/lib/python2.7/site-packages/requests/api.py", line 44, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/lib/ckan/default/lib/python2.7/site-packages/requests/sessions.py", line 279, in request
    resp = self.send(prep, stream=stream, timeout=timeout, verify=verify, cert=cert, proxies=proxies)
  File "/usr/lib/ckan/default/lib/python2.7/site-packages/requests/sessions.py", line 374, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/ckan/default/lib/python2.7/site-packages/requests/adapters.py", line 209, in send
    raise ConnectionError(e)
ConnectionError: HTTPConnectionPool(host='default.ckan.com', port=80): Max retries exceeded with url: /api/3/action/resource_show (Caused by <class 'socket.error'>: [Errno 111] Connection refused)

ckan,solr 运行良好。 8800 端口的数据推送器正在运行。

$ curl localhost:8800

  "help": "\n        Get help at:\n        http://ckan-service-provider.readthedocs.org/."

我的 datapusher 有什么遗漏吗? 谢谢。

我添加了我的ini

cache_dir = /tmp/%(ckan.site_id)s/
beaker.session.key = ckan
beaker.session.secret = CkL+a+Nc6grW1jBM/Ts69mRsE
app_instance_uuid = f41a65ac-4a33-44fe-bb03-af15b456978e
who.config_file = %(here)s/who.ini
who.log_level = warning
who.log_file = %(cache_dir)s/who_log.ini
sqlalchemy.url = postgresql://ckan_default:PASS@localhost/ckan_default
ckan.datastore.write_url = postgresql://ckan_default:PASS@localhost/datastore_default
ckan.datastore.read_url = postgresql://datastore_default:PASS@localhost/datastore_default
ckan.datastore.default_fts_lang = english
ckan.datastore.default_fts_index_method = gist
ckan.site_url = http://ckan.daniel.com
ckan.auth.anon_create_dataset = false
ckan.auth.create_unowned_dataset = false
ckan.auth.create_dataset_if_not_in_organization = false
ckan.auth.user_create_groups = false
ckan.auth.user_create_organizations = false
ckan.auth.user_delete_groups = true
ckan.auth.user_delete_organizations = true
ckan.auth.create_user_via_api = false
ckan.auth.create_user_via_web = true
ckan.auth.roles_that_cascade_to_sub_groups = admin
ckan.site_id = default
solr_url = http://127.0.0.1:8983/solr/ckan
ckan.plugins = stats text_view image_view recline_view datastore datapusher
ckan.views.default_views = image_view text_view recline_view
ckan.site_title = CKAN
ckan.site_logo = /base/images/ckan-logo.png
ckan.site_description =
ckan.favicon = /images/icons/ckan.ico
ckan.gravatar_default = identicon
ckan.preview.direct = png jpg gif csv
ckan.preview.loadable = html htm rdf+xml owl+xml xml n3 n-triples turtle plain atom csv tsv rss txt json
ckan.locale_default = en
ckan.locale_order = en pt_BR ja it cs_CZ ca es fr el sv sr sr@latin no sk fi ru de pl nl bg ko_KR hu sa sl lv
ckan.locales_offered =
ckan.locales_filtered_out = en_GB
ckan.feeds.authority_name =
ckan.feeds.date =
ckan.feeds.author_name =
ckan.feeds.author_link =
ckan.storage_path =  /usr/lib/ckan/korea/src/ckan/filestore
ckan.max_resource_size = 10
ckan.max_image_size = 5
ckan.datapusher.formats = csv xls xlsx tsv application/csv application/vnd.ms-excel application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
ckan.datapusher.url = http://ckan.daniel.com:8800/
ckan.hide_activity_from_users = %(ckan.site_id)s

【问题讨论】:

你能发布你的 production.ini/development.ini 吗?看起来 ckan.site_url 可能是错误的。 我在上面添加了我的ini 我通过将端口从 5000 更改为 80 来解决这个问题。并以 root 身份启动 ckan。但我还有另一个问题。当我单击“上传到数据存储区”时,我可以看到“AttributeError: 'module' object has no attribute 'ReadError'”错误。 我认为,如果您希望这一切都能很好地协同工作,您需要完成生产设置的步骤。以 root 身份在端口 80 上进行调试/开发设置不是一个好主意 我使用的是 redhat 而不是 ubuntu。我可以在redhat上安装ckan作为产品吗?即使源安装,我也可以做 damonize ckan 吗? 【参考方案1】:

正如您在评论中注意到的那样,问题在于 数据推送器正在尝试连接到错误的端口

ConnectionError: HTTPConnectionPool(host='default.ckan.com', port=80): url: /api/3/action/resource_show 超过了最大重试次数(原因:[Errno 111 ] 连接被拒绝)

您已经找到了一种可能的解决方法:将 CKAN 的端口更改为 80。

作为一种替代解决方法,我发现将端口(与[server:main] 部分中的port 配置的端口相同)添加到ckan.site_url 会使数据推送器使用它而不是默认的HTTP 端口(80)。所以,在你的情况下,它可能是:

ckan.site_url = http://default.ckan.com:5000

当然,这只是另一种可能的解决方法; 真正的解决方案是修复数据推送器,以便它正确地从配置中读取端口...

【讨论】:

以上是关于ckan datapusher /api/3/action/resource_show(由 <class 'socket.error'> 引起:[Errno 111] Connection的主要内容,如果未能解决你的问题,请参考以下文章

ckan 2.9.3 容器无法在 Windows 10 上运行

通过 Vagrant 中的共享文件访问 CKAN 源文件

CKAN的替代品[关闭]

cKan 在重启 Apache 服务时安装失败

使用 Azure b2c OpenID Connect 配置 Ckan 的身份验证

json 这是CKAN API的OpenAPI规范定义