Joelbu
Joelbu

Reputation: 92

TcpClient connection closes when being inactive

My .NET MAUI application communicates with a server using a tcpconenction. However, if the user turns his phone off or minimizes the application for a few minutes and then reopens it, the connection is closed. I though about checking if the Stream is not null, else opening a new connection, but is there a way to stop NetworkStreams from closing due to inactivity?

Upvotes: 0

Views: 42

Answers (1)

Dhairyasheel JADHAV
Dhairyasheel JADHAV

Reputation: 1

To maintain the connection, you can use a keep-alive mechanism

Upvotes: 0

Related Questions