ebi-uniprot / uniprot-rest-api

UniProt Website development for Back end services
Apache License 2.0
4 stars 3 forks source link

sslv3 alert handshake failure - error when acces API with python #23

Open bartosz-kozak opened 5 years ago

bartosz-kozak commented 5 years ago

I try to get UniProt ID from list of around 14 000 EMBL accessions. I use python code:

import requests
BASE = 'https://www.uniprot.org'
TOOL_ENDPOINT = '/uploadlists/'

def map_retrieve(ids2map, source_fmt='EMBL',target_fmt='ACC', output_fmt='list'):
    if hasattr(ids2map, 'pop'):
        ids2map = ' '.join(ids2map)
    payload = {'from': source_fmt,
               'to': target_fmt,
               'format': output_fmt,
               'query': ids2map,
              }
    response = requests.get(BASE + TOOL_ENDPOINT, params=payload)
    if response.ok:
        return response.text
    else:
        response.raise_for_status()

When I try to use above function in loop to map all my entries I got an error: SSLError: HTTPSConnectionPool(host='www.uniprot.org', port=443): Max retries exceeded with url: /uploadlists/?from=EMBL&to=ACC&format=list&query=PNT36561+PNT27819+PNT19770+...+PNT25856 (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'ssl3_read_bytes', 'sslv3 alert handshake failure')])")))

In one iteration of the function I send list of 500 ids and use time.sleep(20) and got this error usually in second iteration of the function.

The function without loop (with list of 500 ids) works properly. How can I solve this problem?

Python version: 3.7.3 requests version: 2.21.0 OS: Debian 10

jieluo321 commented 5 years ago

can you repost it to help@uniprot.org

chasemc commented 3 years ago

Same as: https://github.com/Ensembl/ensembl-rest/issues/427

SnehaBheemireddy commented 1 year ago

HTTPError Traceback (most recent call last)

in ----> 1 map_retrieve('P13368') in map_retrieve(ids2map, source_fmt, target_fmt, output_fmt) 15 return response.text 16 else: ---> 17 response.raise_for_status() ~\anaconda3\lib\site-packages\requests\models.py in raise_for_status(self) 941 942 if http_error_msg: --> 943 raise HTTPError(http_error_msg, response=self) 944 945 def close(self): HTTPError: 404 Client Error: Not Found for url: https://rest.uniprot.org/uploadlists/from=EMBL&to=ACC&format=list&query=P13368