What does client.Options.KeepAliveInterval do? I'm trying to keep the connection open at all times (using .net framework 3.5). From past experience, in case of no activity the client (python websocket) would close the connection after 10 minutes but also in case there is activity the server (aws api gateway) would close the connection after 2h.
Running a test for 5 hours, with KeepAliveInterval set to 3h,
ThreadPool.RegisterWaitForSingleObject(
new AutoResetEvent(false),
(state, bTimeout) => Console.WriteLine("Is connected: {0}, state: {1}, time: {2}", client.IsConnected, client.State, DateTimeOffset.UtcNow.ToString("HH:mm:ss")),
"",
TimeSpan.FromSeconds(5),
false);
and the connection is still open
Is connected: True, state: Open, time: 11:07:05
Does the KeepAliveInterval keep the connection alive for at least X time set by this property and then some re-connection logic needs to be implemented to keep the connection open or is there no guarantee for at least X time?
Also tried to test the re-connection like this but only closing part worked, the connecting part failed stating the connection is already opened even though the logs were reporting
Is connected: False, state: Closed, time: 11:08:05
ThreadPool.RegisterWaitForSingleObject(
new AutoResetEvent(false),
(state, bTimeout) => client.Close(),
"",
TimeSpan.FromSeconds(60),
true);
ThreadPool.RegisterWaitForSingleObject(
new AutoResetEvent(false),
(state, bTimeout) => client.Connect(uri),
"",
TimeSpan.FromSeconds(120),
true);
Do I need to dispose and reconstruct the client object in order to reconnect?