Setting ReadTimeout in PgSqlLargeObject throwing exception

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for PostgreSQL
Post Reply
TonyV
Posts: 74
Joined: Wed 25 May 2011 15:03

Setting ReadTimeout in PgSqlLargeObject throwing exception

Post by TonyV » Mon 23 Apr 2012 16:00

I've got the following code in a class in my application:

Code: Select all

public static int PutImageBytes( CarSystemEntities context, byte[] image ) {
    PgSqlConnection connection = ( (EntityConnection) context.Connection ).StoreConnection as PgSqlConnection;

    try {
        if ( connection.State != ConnectionState.Open ) {
            connection.Open();
        }

        PgSqlLargeObject lo = new PgSqlLargeObject( connection );
        lo.ReadTimeout = 0;
        lo.WriteTimeout = 0;

        lo.Create();
        lo.Open();
        lo.Write( image, 0, image.Length );
                lo.Close();

        return lo.Oid;
    } catch ( Exception ex ) {
        throw new DataAccessException( DataAccessOperations.PutImageBytes, FailureReason.DatabaseError, ex );
    }
}
This throws a "System.InvalidOperationException: Timeouts are not supported on this stream" exception on the lo.ReadTimeout = 0 line.

We are trying to keep the Large Object table operation from timing out as this seems to create the invalid connections we have been discussing in my other thread called "What is the cause of the Stream Already Closed" message?

It appears that the ReadTimeout and WriteTimeout properties mentioned in the documentation do not work and have nothing to do with setting the timeout used internally by any commands involved in retrieving data from or writing data to the large objects table. What is the correct way to keep large object operations from timing out?

Tony

TonyV
Posts: 74
Joined: Wed 25 May 2011 15:03

Re: Setting ReadTimeout in PgSqlLargeObject throwing excepti

Post by TonyV » Mon 30 Apr 2012 18:39

Not sure if you guys missed this one as there have been no responses in a week . . .

Shalex
Site Admin
Posts: 8245
Joined: Thu 14 Aug 2008 12:44

Re: Setting ReadTimeout in PgSqlLargeObject throwing excepti

Post by Shalex » Tue 01 May 2012 13:08

Sorry for the delay. We have reproduced and are investigating the issue.

Shalex
Site Admin
Posts: 8245
Joined: Thu 14 Aug 2008 12:44

Re: Setting ReadTimeout in PgSqlLargeObject throwing excepti

Post by Shalex » Fri 04 May 2012 16:55

WriteTimeout and ReadTimeout are the PgSqlLargeObject properties which are inherited from the base Stream class. There is no need to overload these properties because PgSqlLargeObject does not load the PostgreSQL server when writing/reading LO. There is a instantaneous and permanent data exchange via socket. Problems with a bad connection (e.g., slow internet) can be solved with connection.ConnectionTimeout.

Post Reply