Search code examples
pythonpython-3.xresthttpshttplib2

OSError: [Errno 0] Error in httplib2 request


My local python application calls a REST api using httplib2. It has worked fine for over a year. This morning I started to receive the following error:

2018-06-28 12:43:07.001 Python[1722:25727] IMKInputSession [0x7f99e21ac2f0 presentFunctionRowItemTextInputViewWithEndpoint:completionHandler:] : [self textInputContext]=0x7f99dfd48440 *NO* NSRemoteViewController to client, NSError=Error Domain=NSCocoaErrorDomain Code=4097 "connection from pid 0" UserInfo={NSDebugDescription=connection from pid 0}, com.apple.inputmethod.EmojiFunctionRowItem

Initially, I thought this was caused by my openSSL certificate being out of date. I have updated to openSSL 1.1. I have also updated from python 3.6 to 3.7. I am still getting the same error.

The code that makes the call is below.

    connection = httplib2.HTTPSConnectionWithTimeout(URL, 443, timeout = 300)
    print('Connection made')
    self.headers = {"Accept":"application/json", "Authorization":Token}
    print(connection)
    connection.request('GET', request_command, body=None 
    headers=self.headers)
    print('request made')

The error is caused by connection.request().


Solution

  • Ok, found the error. I was using httplib2 version 0.9. I upgraded via:

    pip3 install httplib2==0.11.3
    

    After the upgrade, the issue was resolved.