This is a somewhat technical answer, and one that hardly relates to UX.
Programmatically, when you open a connection you either specify a timeout or take the default. Connections have timeouts for many reasons: Software wise, processes can hang forever without exiting, consuming memory and CPU. The same applies on the hardware level - a server that is down would eventually block many routers around the world if all wait for the connection to be established.
Note that browsers have their own connection timeouts. So sometimes these timeouts have nothing to do with the application itself, but with lower-level software/hardware.
Yet, I think what you experience is simply developers taking the 'default' handling - if the connection times out, just show an error. The alternative is entering a re-connect loop. There are some challenges in timeout recovery because your app enters an 'inconsistent' state as far as 'normal' flow is concerned. You have to introduce buffers, some meaningful feedback to the user, and so forth - so it is a bit of extra effort that is also easier or harder to achieve depending on the app architecture.
My experience is different than yours - a lot of apps or sites handle timeout pretty well. Chrome for example will keep pinging the servers until connection is re-establish and reload all the tabs. TODOist, Spotify, Google Docs etc all handle timeouts pretty well. Maybe I'm just lucky.