In the following code i am collecting data to pandas dataframe called ohlcv as a function and running the app throw to the ib server:
from ibapi.client import EC
The ibapi package disconnects from the socket but the reader is still trying to read from the socket. The source code has been modified to just trap the error but it hasn't made it into a release yet. You can modify your source code like is suggested here. https://groups.io/g/twsapi/message/42580 .