Page 1 of 1

Setting ReadTimeout in PgSqlLargeObject throwing exception

Posted: Mon 23 Apr 2012 16:00
by TonyV
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

Re: Setting ReadTimeout in PgSqlLargeObject throwing excepti

Posted: Mon 30 Apr 2012 18:39
by TonyV
Not sure if you guys missed this one as there have been no responses in a week . . .

Re: Setting ReadTimeout in PgSqlLargeObject throwing excepti

Posted: Tue 01 May 2012 13:08
by Shalex
Sorry for the delay. We have reproduced and are investigating the issue.

Re: Setting ReadTimeout in PgSqlLargeObject throwing excepti

Posted: Fri 04 May 2012 16:55
by Shalex
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.