aiohttp - Fatal read error on socket transport - TimeoutError
<p>We use aiohttp with Python3.5 to post data into elastic search. The post line is as follows:</p>

<pre><code>response = await self._http_session.request(method, url,
                    data = data_fun(), params = params)
</code></pre>

<p>Usually everything runs just fine but from time to time, following error occurs:</p>

<pre><code>Fatal read error on socket transport
protocol: &lt;aiohttp.parsers.StreamProtocol object at 0x7fde5eb7eeb8&gt;
transport: &lt;_SelectorSocketTransport fd=21 read=polling write=&lt;polling, bufsize=261832&gt;&gt;
Traceback (most recent call last):
  File "/usr/lib/python3.5/asyncio/selector_events.py", line 664, in _read_ready
   data = self._sock.recv(self.max_size)
TimeoutError: [Errno 110] Connection timed out
</code></pre>

<p>It would be fine, if it would just raise exception and continue to function normally. In our case it seems though, that this error causes entire asyncio task, in which the post request is executed, to freeze.</p>

<p>We tracked down the error raise to <a href="https://github.com/python/asyncio/blob/master/asyncio/selector_events.py#L674" rel="nofollow">https://github.com/python/asyncio/blob/master/asyncio/selector_events.py#L674</a> which subsequently calls the <code>call_exception_handler</code>.</p>

<p>Is it possible that this exception renders the <code>_https_session</code> invalid/unusable and we need to create new one? Or is there anything else we can do about it?</p>