Error "Cannot access a closed Stream" when an underlying TCP connection gets silently closed
When I open a connection to Vertica (not pooled) using the ado.net driver and execute a query, everything works fine.
However, if for any reason, the underlying tcp/ip connection is closed (eg. network issue), and I try to reuse the open Vertica connection, I receive the following error(s):
First try to use the connection, eg. by calling the Prepare() method of the dbcommand:
 Int32 offset, Int32 count)
--- End of inner exception stack trace ---
at System.Net.Sockets.NetworkStream.Write(Byte buffer, Int32 offset, Int32 count)
at: at Vertica.Data.Internal.ADO.Net.SCommand.ExecuteReader(CommandBehavior behavior)
at Vertica.Data.Internal.ADO.Net.SCommand.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.Common.DbCommand.ExecuteDbDataReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken)
Cannot access a closed Stream.
at: at System.IO.BufferedStream.ReadByteSlow()
at Vertica.Data.Internal.DataEngine.VResultSet.FetchChunk(Boolean clearExistingRowCache)
at Vertica.Data.Internal.Core.VConnection.EnsureNotInLRS(String query)
at Vertica.Data.Internal.DataEngine.VDataEngine.PrepareImpl(String sqlQuery, Boolean isBatch)
at Vertica.Data.Internal.DataEngine.VDataEngine.Prepare(String sql)
at Vertica.Data.Internal.ADO.Net.SCommand.Prepare(Boolean isExecDirect)
It looks like the Vertica ado.net driver is unaware of the network condition, and tries to use the stream, even if it is unusable (eg. closed or broken).
I haven't found any method on VerticaConnection object that would help me work around that. The connection state is Open, I can create a command on it (because no network calls).
Could you help to resolve the issue?