title: SSL: APPLICATION_DATA_AFTER_CLOSE_NOTIFY Error
body: <p>I am sending multiple requests with aiohttp using tor's http proxy (with aiohttp_socks)</p>
  <p>After some requests are done I am getting the following error:</p>
  <pre><code>Traceback (most recent call last):
    File &quot;main.py&quot;, line 171, in &lt;module&gt;
      loop.run_until_complete(future)
    File &quot;/usr/lib/python3.8/asyncio/base_events.py&quot;, line 616, in run_until_complete
      return future.result()
    File &quot;main.py&quot;, line 95, in get_market_pages
      async with session.get(active_link, headers=headers) as response:
    File &quot;/home/mrlalatg/.local/lib/python3.8/site-packages/aiohttp/client.py&quot;, line 1012, in __aenter__
      self._resp = await self._coro
    File &quot;/home/mrlalatg/.local/lib/python3.8/site-packages/aiohttp/client.py&quot;, line 504, in _request
      await resp.start(conn)
    File &quot;/home/mrlalatg/.local/lib/python3.8/site-packages/aiohttp/client_reqrep.py&quot;, line 847, in start
      message, payload = await self._protocol.read()  # type: ignore  # noqa
    File &quot;/home/mrlalatg/.local/lib/python3.8/site-packages/aiohttp/streams.py&quot;, line 591, in read
      await self._waiter
  aiohttp.client_exceptions.ClientOSError: [Errno 1] [SSL: APPLICATION_DATA_AFTER_CLOSE_NOTIFY] application data after close notify (_ssl.c:2745)
  </code></pre>
  <p>I can't find any information about this error, except the git discussion about a similar one - <a href="https://github.com/aio-libs/aiohttp/issues/3535" rel="nofollow noreferrer">github</a></p>
  <p>There I found a workaround (<a href="https://github.com/aio-libs/aiohttp/issues/3535#issuecomment-483268542" rel="nofollow noreferrer">link</a>) that I can modify to ignore this error, but it didn't work, the error is still there.</p>
  <p>The modified version of a workaround:</p>
  <pre class="lang-py prettyprint-override"><code>SSL_PROTOCOLS = (asyncio.sslproto.SSLProtocol,)
  try:
      import uvloop.loop
  except ImportError:
      pass
  else:
      SSL_PROTOCOLS = (*SSL_PROTOCOLS, uvloop.loop.SSLProtocol)
  
  def ignore_aiohttp_ssl_eror(loop):
      &quot;&quot;&quot;Ignore aiohttp #3535 / cpython #13548 issue with SSL data after close
  
      There is an issue in Python 3.7 up to 3.7.3 that over-reports a
      ssl.SSLError fatal error (ssl.SSLError: [SSL: KRB5_S_INIT] application data
      after close notify (_ssl.c:2609)) after we are already done with the
      connection. See GitHub issues aio-libs/aiohttp#3535 and
      python/cpython#13548.
  
      Given a loop, this sets up an exception handler that ignores this specific
      exception, but passes everything else on to the previous exception handler
      this one replaces.
  
      Checks for fixed Python versions, disabling itself when running on 3.7.4+
      or 3.8.
  
      &quot;&quot;&quot;
  
      orig_handler = loop.get_exception_handler()
  
      def ignore_ssl_error(loop, context):
          if context.get(&quot;message&quot;) in {
              &quot;SSL error in data received&quot;,
              &quot;Fatal error on transport&quot;,
          }:
              # validate we have the right exception, transport and protocol
              exception = context.get('exception')
              protocol = context.get('protocol')
              if (
                  isinstance(exception, ssl.SSLError)
                  and exception.reason == 'APPLICATION_DATA_AFTER_CLOSE_NOTIFY'
                  and isinstance(protocol, SSL_PROTOCOLS)
              ):
                  if loop.get_debug():
                      asyncio.log.logger.debug('Ignoring asyncio SSL KRB5_S_INIT error')
                  return
          if orig_handler is not None:
              orig_handler(loop, context)
          else:
              loop.default_exception_handler(context)
  
      loop.set_exception_handler(ignore_ssl_error)
  </code></pre>