调用抽象语义表示接口连接超时

我最近在使用hanlp的抽象语义表示接口时总是报连接超时的错误,具体的使用和报错信息如下:

调用代码:
graphs = HanLP.abstract_meaning_representation(‘男孩希望女孩相信他。’)

报错信息:
TimeoutError: The read operation timed out

The above exception was the direct cause of the following exception:

ReadTimeoutError Traceback (most recent call last)
ReadTimeoutError: HTTPSConnectionPool(host=‘www.hanlp.com’, port=443): Read timed out. (read timeout=60)

During handling of the above exception, another exception occurred:

ReadTimeout Traceback (most recent call last)
/usr/local/lib/python3.10/dist-packages/requests/adapters.py in send(self, request, stream, timeout, verify, cert, proxies)
530 raise SSLError(e, request=request)
531 elif isinstance(e, ReadTimeoutError):
→ 532 raise ReadTimeout(e, request=request)
533 elif isinstance(e, _InvalidHeader):
534 raise InvalidHeader(e, request=request)

ReadTimeout: HTTPSConnectionPool(host=‘www.hanlp.com’, port=443): Read timed out. (read timeout=60)

在1月27日的使用是正常的,从1月28日起连接超时,请问有什么解决方法吗?

请问您的问题解决了吗?
我将接口修改为HanLP = HanLPClient(‘https://www.hanlp.com/hanlp/v21/redirect’, auth=auth)后还是有相同的报错

您好,问题目前还没有解决。2月6日左右联系过hanlp的官方团队反映过这个问题,hanlp给出的答复是会尽快修复。

已经作出相应调整,但用户量太大,如果还遇到超时问题,可以试试在闲时调用,比如深夜或凌晨。

您好,感谢您的回复。我在凌晨尝试调用抽象语义表示的接口,分别在本地环境和colab环境中运行了示例代码,但是依然有超时的问题。
我的代码如下:
from hanlp_restful import HanLPClient
HanLP = HanLPClient(‘https://www.hanlp.com/api’, auth=None, language=‘en’) #这里我将auth换成了申请的秘钥
graphs = HanLP.abstract_meaning_representation(‘The boy wants the girl to believe him.’)
len(graphs)

报错信息如下:
Traceback (most recent call last):
File “api.py”, line 3, in
graphs = HanLP.abstract_meaning_representation(‘The boy wants the girl to believe him.’)
File “/Users/cwy/miniconda3/envs/chatgpt/lib/python3.8/site-packages/hanlp_restful/init.py”, line 362, in abstract_meaning_representation
return self._send_post_json(self._url + ‘/abstract_meaning_representation’, {
File “/Users/cwy/miniconda3/envs/chatgpt/lib/python3.8/site-packages/hanlp_restful/init.py”, line 156, in _send_post_json
return json.loads(_post(url, form, headers, self._timeout, verify=self._verify))
File “/Users/cwy/miniconda3/envs/chatgpt/lib/python3.8/site-packages/hanlp_restful/init.py”, line 17, in _post
response = requests.post(url, json=form, headers=headers, timeout=timeout, verify=verify)
File “/Users/cwy/miniconda3/envs/chatgpt/lib/python3.8/site-packages/requests/api.py”, line 115, in post
return request(“post”, url, data=data, json=json, **kwargs)
File “/Users/cwy/miniconda3/envs/chatgpt/lib/python3.8/site-packages/requests/api.py”, line 59, in request
return session.request(method=method, url=url, **kwargs)
File “/Users/cwy/miniconda3/envs/chatgpt/lib/python3.8/site-packages/requests/sessions.py”, line 587, in request
resp = self.send(prep, **send_kwargs)
File “/Users/cwy/miniconda3/envs/chatgpt/lib/python3.8/site-packages/requests/sessions.py”, line 701, in send
r = adapter.send(request, **kwargs)
File “/Users/cwy/miniconda3/envs/chatgpt/lib/python3.8/site-packages/requests/adapters.py”, line 578, in send
raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: HTTPSConnectionPool(host=‘www.hanlp.com’, port=443): Read timed out. (read timeout=60)

做了一下优化,请重试。

好的,非常感谢!现在可以正常使用了