mfenniak / rethinkdb-net

A C# / .NET client driver for RethinkDB.
Other
247 stars 37 forks source link

Connection is hanging when server is down #245

Open krabishe opened 8 years ago

krabishe commented 8 years ago

Hi, thanks for your work. I found out, there is no way to determine that server is down after successful connect.

var connFactory = new ReliableConnectionFactory(new DefaultConnectionFactory(...));
var tsc = new CancellationTokenSource();

using (var conn = connFactory.Get())
{
    foreach (var change in conn.Run(new DbQuery("db").Table<Foo>("table").Changes(), cancellationToken: tsc.Token))
    {
        Console.WriteLine(change.NewValue.Id);
    }
}

After stopping the rethinkdb server these messages appear in logs:

Debug: Received 0 / 8 bytes of packet
Debug: ReadLoop terminated by network exception; this is expected if the connection was closed inten
tionally
Warning: 1 queries were still waiting for responses from a connection that is closing; they'll recei
ve exceptions instead
Debug: InternalRunQuery: beginning process of transmitting query w/ token 2
Debug: InternalRunQuery: acquired write lock for query token 2
Debug: InternalRunQuery: writing query token 2
Information: JSON query: [3]
Debug: Writing packet, 3 bytes
Debug: InternalRunQuery: waiting for response for query token 2

There aren't any exceptions in my code, despite of Warning in log. Any suggestions?