We'd have to see some code of yours. But basically TCP connections have a timeout and should naturally die if there is no traffic on the connection within a defined period of time so it shouldn't be the case.