bchavez / RethinkDb.Driver

:headphones: A NoSQL C#/.NET RethinkDB database driver with 100% ReQL API coverage.
http://rethinkdb.com/api/java
Other
384 stars 134 forks source link

ConnectionPool.Seed does not like hostnames #85

Closed oliverjanik closed 8 years ago

oliverjanik commented 8 years ago

Any reason why IP addresses are enforced?

bchavez commented 8 years ago

DNS complicates things with connection pools.

Dns.GetHostAddresses("server.domain.com") returns an array of IPAddress[].

Maybe you see where I'm going with this... =(

I tried adding DNS support twice and failed both times because the code got way too complicated trying to handle all scenarios in a reasonable way.

If you can come up with a reasonable solution that deals with all the issues without adding significant complexity to the connection pooling code I'd be open to hearing new ideas.

I've found it is best to "BYODNS" (aka bring your own DNS) where, you do the DNS resolving yourself in your app before booting up the driver... then build a dynamic Seed list the correct format IP:Port (this why you know exactly what you're getting in terms of IP addressing), then tell the driver to ConnectionPool(seeds).Connect().

All the while, the connection pooling code is kept _simple_ and the surface area of unexpected behavior is kept at bay. :smile_cat:

HTH, Brian

:ear_ofrice: :stew: [**"Out here in the fields... I fight for my meals... It's only teenage wasteland..."**_](https://www.youtube.com/watch?v=IXWNSb4nUDY)

oliverjanik commented 8 years ago

Great explanation. How do you deal with multiple IPs in Connection().Hostname() ?

bchavez commented 8 years ago

Seems like we're using Dns.GetHostAddressesAsync :scream_cat: when the user is using a single connection.

When Dns.GetHostAddressesAsync returns multiple IPs, we loop each IP returned by DNS until we get a successfully connected TCP socket. The first successful TCP connect wins and we stop trying any remaining IPs.

I think it's a bit easier to debug and deal with a single connection with Hostname than a host pool of 'em (and the problems they bring).

:watch: :citysunset: [**"I just can't wait... I just can't wait... for saturday night..."**_](https://www.youtube.com/watch?v=wOjGmpmvGz8#t=2m)

bchavez commented 8 years ago

Sup Oliver ... gonna close this issue, but feel free to reopen if you feel this is a serious issue for the driver and you can come up with a good solution that resolves the complexity issues .

:star: :basketball: _"Hey, now, you're an All Star, get your game on..."_