npgsql: Exception while reading from stream

Hi, I’m using Npgsql 3.1.7 since yesterday when I have updated it to 3.1.8 via Nuget but I get the same exception.

I’m connecting to Windows server 2012 and Postgresql 9.5 also tryed Postgresql 9.4 on Debian 8 with the same behavior.

What I’m trying to do is to select data via COPY command using Npgsql BeginBinaryExport but after some seconds the exception is thrown. This happens every run. I tryed to apply Pooling=false,Keepalive=10, commandtimeout=0 to the connection string without success.

I’m getting:

Exception while reading from stream
Unable to read data from the transport connection: Unable to establish connection. Wrong answer from the connected part after a timeout interval or missing response`. 
This last part is in italian, I tryed to translate it, I hope you can understand it anyway.

Here the StackTrace:

Exception thrown: 'Npgsql.NpgsqlException' in Npgsql.dll
in Npgsql.ReadBuffer.Ensure(Int32 count, Boolean dontBreakOnTimeouts)
   in Npgsql.NpgsqlConnector.DoReadMessage(DataRowLoadingMode dataRowLoadingMode, Boolean isPrependedMessage)
   in Npgsql.NpgsqlConnector.ReadMessageWithPrepended(DataRowLoadingMode dataRowLoadingMode)
   in Npgsql.NpgsqlConnector.ReadExpecting[T]()
   in Npgsql.NpgsqlBinaryExporter..ctor(NpgsqlConnector connector, String copyToCommand)
   in Npgsql.NpgsqlConnection.BeginBinaryExport(String copyToCommand)

EDIT: I tryed to change the command from COPY(select) to a simple select using NpgsqlCommand and it works, but if I remove Pooling=false,Keepalive=10, commandtimeout=0 from the connectionstring the exeption returns.

I forgot to say that I’m working with a remote server.

any idea? Thanks Marco

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 15 (6 by maintainers)

Most upvoted comments

I had similar issue. What was strange for me was it was working on locally installed postgresql but was not working on AWS. after reading @kuznero comment on upgrading to 3.2.2 i checked what version i installed. it was 3.1.0. I upgraded to 3.2.5 , Wooohaa. ITS WORKING NOW.

Thanks for help.