Skip to content

ConfigurationOptions.ToString does not add brackets to IPv6 address #2811

@okay9109

Description

@okay9109

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 brackets

From 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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions