Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
mari3728 opened this issue Oct 30, 2024 · 6 comments · Fixed by #2813
Closed

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

mari3728 opened this issue Oct 30, 2024 · 6 comments · Fixed by #2813

Comments

@mari3728
Copy link

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.

@mari3728 mari3728 changed the title ConfigurationOptions.ToString does not properly convert IPv6 address to string ConfigurationOptions.ToString does not add brackets to IPv6 address Oct 30, 2024
@mgravell
Copy link
Collaborator

Agreed, we need some when love here

@mgravell
Copy link
Collaborator

working on it ^^^

@mari3728
Copy link
Author

Thanks for the swift fix! Is there an ETA for the next release of StackExchange.Redis package?

@mgravell
Copy link
Collaborator

Actually, 2.8.18 is available right now on the myget preview feed (https://www.myget.org/gallery/stackoverflow) - it would be super useful if you're able to try against that build, and check whether it works as you expect (it is the exact same build, as produced by the build-server - just not yet published on NuGet)

@mari3728
Copy link
Author

I have installed the version mentioned and it works as expected, thank you!
image

@mgravell
Copy link
Collaborator

Great! There's a few hoops to jump through for a "proper" release (tags, release notes, deploys, etc) - shouldn't be long, but you can happily keep using the myget one for now.

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

Successfully merging a pull request may close this issue.

2 participants