Setting ReadTimeout in PgSqlLargeObject throwing exception

Setting ReadTimeout in PgSqlLargeObject throwing exception

Postby 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

Postby TonyV » Mon 30 Apr 2012 18:39

Not sure if you guys missed this one as there have been no responses in a week . . .
TonyV
 
Posts: 74
Joined: Wed 25 May 2011 15:03

Re: Setting ReadTimeout in PgSqlLargeObject throwing excepti

Postby Shalex » Tue 01 May 2012 13:08

Sorry for the delay. We have reproduced and are investigating the issue.
Shalex
Devart Team
 
Posts: 7654
Joined: Thu 14 Aug 2008 12:44

Re: Setting ReadTimeout in PgSqlLargeObject throwing excepti

Postby 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.
Shalex
Devart Team
 
Posts: 7654
Joined: Thu 14 Aug 2008 12:44


Return to dotConnect for PostgreSQL