Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Server timeout is lost with default port #54

igorberger opened this Issue Aug 28, 2012 · 5 comments


None yet
2 participants

If "Server" part of connection string doesn't contain a port, Server.Timeout will always be set to 0 in ConnectionBuilder(connectionString). This creates a problem if multiple servers are specified, since the timeout must be non-zero in that case.


nberardi commented Aug 29, 2012

I am unable to verify this. Do you gave a test case.

@nberardi nberardi closed this Aug 29, 2012

@nberardi nberardi reopened this Aug 29, 2012

@nberardi nberardi was assigned Aug 29, 2012

This issue affects single server config as well. E.g., after this code:

  var t1 = new ConnectionBuilder("Server=host:123;Connection Timeout=5").Servers[0].Timeout;
  var t2 = new ConnectionBuilder("Server=host;Connection Timeout=5").Servers[0].Timeout;

t1 is 5, but t2 is 0.


nberardi commented Aug 29, 2012

put Connection Timeout before defining the Servers. The connection string is currently parsed in order.

Unfortunately that doesn't help. The problem is in this code:

if (serverParts.Length == 2)
  int port;
  if (Int32.TryParse(serverParts[1], out port))
    Servers.Add(new Server(host: host, port: port, timeout: ConnectionTimeout.Seconds));
    Servers.Add(new Server(host: host, timeout: ConnectionTimeout.Seconds));
  Servers.Add(new Server(host));

When serverParts.Length != 2 (e.g., no port specified), the final else creates a Server object without passing the timeout.


nberardi commented Aug 29, 2012

Ok, if you want I do accept pull requests.

@nberardi nberardi closed this Sep 12, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment