-
Notifications
You must be signed in to change notification settings - Fork 150
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
Cannot reconnect to Nats cluster #195
Comments
@sasbury This is correct analysis. The server sends connect URLs of all servers in the cluster in the form IP:port, without a scheme (or username and password for that matter). The client library is responsible for adding it. |
I made a quick fix to add |
Should get this fixed this week, I have other tasks in there anyway
…On Sun, Nov 25, 2018, 12:26 PM Ivan Kozlovic ***@***.*** wrote:
@sasbury <https://github.com/sasbury> This is correct analysis. The
server sends connect URLs of all servers in the cluster in the form
IP:port, without a scheme (or username and password for that matter). The
client library is responsible for adding it.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#195 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ADKH0esNe-152lNqL9WEETMLGuyhPqgnks5uyvzugaJpZM4YyCjY>
.
|
@fajran Adding "nats://" unconditionally may not be the right thing to do. Not sure about the Java library, but some libraries have distinct behavior if the scheme is set to "tls" when TLS is wanted. |
@kozlovic you are right. I was not considering that or even username/password. |
@fajran No worries. Your analysis of the issue was spot on. Thanks! |
I think my easiest option right now is to use all individual Nats server that I have in the cluster and set the looking forward for the proper fix! thanks! |
ok, it turns out blindly adding nats:// is not necessarily bad, because the place that was failing doesn't care about the protocol. BUT, i did a new fix that is a bit more careful and checks the URI in all the places we use it. I am re-running tests and will commit momentarily into v2.4.0 branch. Hoping to release that branch this week, but if you get a chance to try before I release it would be awesome just in case the tests miss something. Oh, i also fixed the unit test that was for servers in info to remove the nats:// to test this. |
I have a Nats cluster setup. When the Nats server that is being used by the java app is terminated, the app tries to reconnect but it throws the following exception.
From what I can see, Nats publishes all addresses of Nats servers in the cluster in the following format
ip-address:port
without the scheme. Check theconnect_urls
values below.When the Nats client tries to reconnect, it will use one of those addresses and create a
java.net.URI
instance from it. Looks like the URI class does not accept aip-address:port
format. Running the code below, will throws the same exception.However, if the
nats
scheme is added, the URI will work fine.Should the
nats://
scheme be always used when building the server list in NatsConnection#getServers()?Actually, it is not possible to a Nats server by addressing it without the scheme because looks like java.net.URI requires a scheme. None of the following code works.
The text was updated successfully, but these errors were encountered: