-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Labels
Description
Hello!
I'm having an issue when calling ConfigurationOptions.ToString method, when my connection string has an IPv6 address.
Just for some context, I'm using Redis as a backplane for SignalR and I parse my original connection string to enhance it. Then, I convert it back to string to pass it to RedisScaleoutConfiguration ([email protected] - I'm using .Net Framework 4.8).
That's why I need to use ConfigurationOptions.ToString method, and I'd expect my connection string IPv6 address to have brackets added to it.
The following example reproduces the behavior:
var connectionString = "[::1]:6379,password=mypass";
var configuration = ConfigurationOptions.Parse(connectionString);
configuration.AbortOnConnectFail = false;
configuration.ClientName = "my-client-name";
var converted = configuration.ToString();
Console.WriteLine(converted); //expected [::1]:6379, actual: ::1:6379
var endpoint = configuration.EndPoints.FirstOrDefault().ToString();
Console.WriteLine(endpoint); //EndPoint.ToString method correctly adds the bracketsFrom my observation, the ConfigurationOptions.ToString method writes the endpoints using Format class, which directly writes the IP address without checking if that's an IPv6 address.