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
Can StackExchange.Redis connection without port work in Docker bridge network? #2562
Comments
I'm intrigued - those two things should be functionally identical... I'll see what I can find. |
With a local using StackExchange.Redis;
using var muxer = ConnectionMultiplexer.Connect("redis,abortConnect=false,password=xxx");
var ttl = await muxer.GetDatabase().PingAsync();
Console.WriteLine($"connected; ttl={ttl.TotalMilliseconds}ms"); with output: connected; ttl=0.6956ms Do you have a runnable repro? I'm not seeing any failure here. Also: what library version are you using? Finally, is there a stack trace on that message, so we can see where it is originating? |
I think what you're actually doing is this: var server = muxer.GetServer("redis"); Now, that parameter is called
That's not a terrible idea, but today: it doesn't do that. Workaround for today: var server = muxer.GetServer(muxer.GetEndPoints().Single()); or var server = muxer.GetServers().Single(); |
So: I did a spike, and the changes needed to do this aren't huge, but: it adds complexity. The only scenario I can think of when people don't want to be really precise with their endpoints is: single endpoint - and in that scenario, the two approaches shown above already give a simple solution. They're also more efficient, I think - as to do this the magic way would require two sets of endpoint allocation. IMO: leave it alone. Before I conclude that, have I correctly interpreted the scenario, and do the workarounds shown above work? |
Hi Marc, And I've tried your solution that perfectly meets my needs. |
I am developing an ASP.NET Core project and using StackExchange.Redis to connect to a Redis instance running in a Docker container. My .NET project is also running in a Docker container, and both containers are in the same Docker bridge network.
The Redis container is named "redis", so this way works => ConnectionMultiplexer.Connect("redis:6379,abortConnect=false,password=xxx")
However, if I remove the port from the connection string, it doesn't work => ConnectionMultiplexer.Connect('redis,abortConnect=false,password=xxx'). I receive the message: "The specified endpoint is not defined (Parameter 'endpoint')"
I'm aware that we can use container name as a host to connect without specifying the port in the same Docker bridge network. But is it necessary to include the port in the StackExchange.Redis connection?
The text was updated successfully, but these errors were encountered: