npgsql: Bad timeout on internal commands

Hi all,

I have just migrated to RC2, and therefore updated NpgSql package.

The issue is the following exception: "Unable to read data from the transport connection: Operation timed out." [string]

It was thrown in the EnsureCreated method. Setting Polling=false seemed to solve the problem. Now I am able to read the database.

However, when I am trying to add a record, this exception is thrown again.

I have my old version (with old RC1 package) running and working fine, so I think my code and database are alright.

Thank you in advance!

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 42 (18 by maintainers)

Commits related to this issue

Most upvoted comments

I also had occasional problems with timeouts and setting CommandTimeout=300 helped (surprisingly setting CommandTimeout=0 was still causing timeout expections). I guess there might be two problems: default is not good, value 0 is not properly handled (or passed to the lower stack).

Sorry everyone, this turned out to be a very silly (but deadly) bug when setting timeouts on internal commands (e.g. when Npgsql starts a transaction). Timeouts are given in seconds, but in a particular case weren’t being multiplied by 1000 before setting the actual socket timeout value. So instead of setting 30000 (30 seconds), 30 was set (30ms). This is why this slipped through testing.

Wow!!!

Confirmed: setting value CommandTimeout=300 does fix my issue! (At least at the first look, I’ll let everybody know if other issues are there).

On the other hand, there probably is a bug with default timeout and setting it to 0.

Thank you @roji and @kskalski