SapientGuardian / mysql-connector-net-netstandard

ADO.NET driver for MySQL targeted against netstandard 1.3
GNU General Public License v2.0
46 stars 15 forks source link

Throw exception when unqualified domain name is provided as Server #31

Closed Nick-Lucas closed 7 years ago

Nick-Lucas commented 7 years ago

Right now if I provide "server=subdomain.domain.com" in the connection string, the driver will accept the input and try to connect, but just hang infinitely.

If I qualify it as "server=MySqlServer.subdomain.domain.com" then it will connect successfully.

I believe this is by design, and for good reason, that you must qualify it. But since the other form is invalid, and the result is so ambiguous to a developer, I believe some appropriate type of exception should be thrown.

This solution was found here: http://stackoverflow.com/a/2938730/5269553

Nick-Lucas commented 7 years ago

This should be quite easy to validate, and I would be happy to contribute it myself. However, I'm not sure if there are other forms that need to be valid, which change the way validation should occur, so wanted to make sure I create an issue for discussion first.

SapientGuardian commented 7 years ago

I think there's a couple issues here. mysqlserver.subdomain.domain.com and subdomain.domain.com are completely different hosts (unless you set up some DNS trickery). When people talk about unqualified or fully qualified domains, they mean the difference between mysqlserver and mysqlserver.subdomain.domain.com where subdomain.domain.com is perhaps your default DNS suffix in your operating system or DNS configuration.

You should be able to put Connection Timeout=5 into your connection string to make it throw an exception after 5 seconds of not being able to connect.

If even after adding that to your connection string, it still waits indefinitely without throwing an exception, that sounds like something that needs to be addressed.

eByte23 commented 7 years ago

@Nick-Lucas I believe @SapientGuardian is 100%, I have previously connected to aws mysql instance for testing which has a domain like db1234.cwitmgwsprn8.us-west-2.rds.amazonaws.com I can confirm that has worked for me.

Nick-Lucas commented 7 years ago

Thanks both! I'll try this out tomorrow :)

Nick-Lucas commented 7 years ago

Okay I'm now reasonably certain the 'fix' was a coincidence.

Looks like this doesn't work whenever I use a domain, but works fine when I use the IP directly. It's probably not be directly related to this provider though, so I need to do some more digging into this at a later date.