rethinkdb-net icon indicating copy to clipboard operation
rethinkdb-net copied to clipboard

Add documentation for manually connecting to DB

Open spiffytech opened this issue 10 years ago • 6 comments

The README only documents configuring a connection with App.config and connecting via a connectionFactory. Please add documentation for manually creating a connection by passing host, port, etc. parameters into the required functions.

spiffytech avatar Feb 06 '15 04:02 spiffytech

asp.net 5 / dnx projects don't have xml based config files like web.config or app.config.

Is there a sample of doing configuration without xml ?

cecilphillip avatar Aug 05 '15 05:08 cecilphillip

Hey @cecilphillip; while this obviously isn't documented, the code that creates the IConnectionFactory object is located here (https://github.com/mfenniak/rethinkdb-net/blob/master/rethinkdb-net/Configuration/ConfigurationAssembler.cs). It is relatively straight-forward -- a DefaultConnectionFactory is created and passed a list of endpoints for a cluster (host/port combinations), and then that connection factory is wrapped in a reliable connection factory and a connection-pooling connection factory if desired.

mfenniak avatar Aug 05 '15 22:08 mfenniak

I had to put this down for a second, but I've tried a few options and they're not working out for me. Maybe I'm missing something. Here's my app.config with a not real IP.

<rethinkdb>
        <clusters>
            <cluster name="example">
                <defaultLogger enabled="true" category="Warning" />
                <connectionPool enabled="true" />
                <networkErrorHandling enabled="true" />
                <endpoints>
                    <endpoint address="1.1.1.1" port="28015" />
                </endpoints>
            </cluster>
        </clusters>
    </rethinkdb>

using var conn = ConfigurationAssembler.CreateConnectionFactory("example"); works fine.

None of the following attempts were successful for me. Instead, I got an AggregateException with an inner exception of RethinkDbNetworkException - Failed to resolve a connectable address

var conn = new RethinkDb.Connection(new IPEndPoint(IPAddress.Parse("1.1.1.1"), 28015));
var conn = new NewtonsoftConnectionFactory(new[] { new IPEndPoint(IPAddress.Parse("1.1.1.1"), 28015) }).Get();


List<EndPoint> endpoints = new List<EndPoint>();
IPAddress ip = IPAddress.Parse("1.1.1.1");
endpoints.Add(new IPEndPoint(ip, 28015));
var factory = new NewtonsoftConnectionFactory(endpoints)
 {
     Logger = new DefaultLogger(LoggingCategory.Information, Console.Out)
 };
var factory = new ConnectionPoolingConnectionFactory( new ReliableConnectionFactory( factory )); 
var conn = factory.Get();         

cecilphillip avatar Aug 18 '15 19:08 cecilphillip

Hi,

Did this ever get resolved? We have the same exception in a very different situation when we use code to create factory rather than giving it in settings. We are creating the DefaultConnectionFactory and everything works fine (we can query, insert/update/delete data) until the load increases. If there are more number of threads accessing rethinkdb server (VM hosted on Azure), suddenly the exception about " Failed to resolve a connectable address" starts coming up. We tried putting in the IP and the URL of the VM but of no use. We are calling .Dispose() on connection after our requests are done.

To Complicate things further, we have 2 web servers and 1 webjob (azure cronjob equivalent). Once the error starts coming, it appears on all three. If we restart the webjob (that creates more connections) everything comes back.

Any clues? I can share the code too if needed but its pretty similar to the one above.

smhassan avatar Mar 16 '16 12:03 smhassan

@smhassan with all due respect, I moved on to using RethinkDb.Driver. Mainly because it follows the conventions of the other official drivers and Brian is very responsive with issues

cecilphillip avatar Mar 17 '16 13:03 cecilphillip

@cecilphillip thanks for replying, I have been thinking of shifting to that too and your recommendation gives me more confidence to spend the time to do it now.

smhassan avatar Mar 17 '16 16:03 smhassan