Both the remote server, the local server, and any intervening network devices such as firewalls or traffic filters can
close the connection for various reasons, there are dozens of possibilities.
Idle timeouts are the most common reason; lifetime timeouts are probably 2nd most common.