This is caused by:
- most usually, writing to a connection when the other end has already closed it;
- less usually, the peer closing the connection without reading all the data that is already pending at his end.
So in both cases you have a poorly defined or implemented application protocol.
There is a third reason which I will not document here but which involves the peer taking deliberate action to reset rather than properly close the connection.