A connection that hangs instead of failing is often stuck on a timer. The -o option makes ss print those timers next to every socket.
ss -tno state established
Each line now ends with something like timer:(keepalive,58sec,0). The first field is the kind of timer, the second is how long until it fires, and the last number counts how many times it already fired.
The kinds tell you a lot. keepalive means the program asked for TCP keepalives, so a dead peer will be noticed sooner or later. on is the retransmit timer: data was sent and the other side has not acknowledged it yet. If that counter keeps climbing, packets are getting lost somewhere along the path. timewait belongs to connections that are already closed and only waiting out their last minute.
A connection with no timer at all is idle and has no keepalive. If the far end disappears without a goodbye, the kernel will not notice until the program writes something, so an idle database connection behind a firewall can look healthy for hours.
I like it with a port filter, like ss -tno state established '( dport = :5432 )', so you only look at one service. The timers move fast, so run it a few times before you draw conclusions from a single line.
Further reading: ss(8) manual page, tcp(7) manual page