python: [Errno 10054] An existing connection was forcibly closed by the remote host

后端 未结 4 948
失恋的感觉
失恋的感觉 2020-11-29 02:53

I am writing python to crawl Twitter space using Twitter-py. I have set the crawler to sleep for a while (2 seconds) between each request to api.twitter.com. However, after

4条回答
  •  余生分开走
    2020-11-29 03:30

    For me this problem arised while trying to connect to the SAP Hana database. When I got this error,

    OperationalError: Lost connection to HANA server (ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))

    I tried to run the code for connection(mentioned below), which created that error, again and it worked.

    
        import pyhdb
        connection = pyhdb.connect(host="example.com",port=30015,user="user",password="secret")
        cursor = connection.cursor()
        cursor.execute("SELECT 'Hello Python World' FROM DUMMY")
        cursor.fetchone()
        connection.close()
    
    

    It was because the server refused to connect. It might require you to wait for a while and try again. Try closing the Hana Studio by logging off and then logging in again. Keep running the code for a number of times.

提交回复
热议问题