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

Setting multi-lines URLS for STAN servers #276

Closed
DeployChef opened this issue Aug 19, 2019 · 2 comments
Closed

Setting multi-lines URLS for STAN servers #276

DeployChef opened this issue Aug 19, 2019 · 2 comments

Comments

@DeployChef
Copy link

For example, I setted:
Options.NatsURL = "nats: //127.0.0.1: 4222, nats: //127.0.0.1: 4223, nats: //127.0.0.1: 4224";
It is not a valid value because the connection string is not parsed when you called stan connection factory.
When a factory is called from STAN, the Nats factory method is called where there is no call to opts.processUrlString (url);
Thus, the string is not parsed.

This leads to the fact that it is impossible to connect to a set of servers

@ColinSullivan1
Copy link
Member

@DeployChef , Thank you for raising this issue.

This was an issue but has been resolved, see nats-io/stan.net#125. We haven't cut a release with the fix yet, but I'll look into doing so soon.

In the meantime, you can setup a core NATS connection, and then pass it to the STAN client. This is what will be required later if you want to enable TLS.

An example of creating a core NATS connection and passing it into STAN can be found here: https://github.com/nats-io/stan.net#enabling-tls

Note that you don't necessarily need to setup TLS. This is how the code might look:

        static IConnection createNATSConnection()
        {
            // get the default NATS options
            var natsOptions = ConnectionFactory.GetDefaultOptions();
            natsOptions.Url = "nats://127.0.0.1:4222, nats://127.0.0.1:4223, nats://127.0.0.1:4224"

            return new ConnectionFactory().CreateConnection(natsOptions);
        }

        static void Main(string[] args)
        {
            // Get default STAN options, then create and assign a
            // core NATS connection for the streaming client to use.
            var stanOptions = StanOptions.GetDefaultOptions();
            stanOptions.NatsConn = createNATSConnection();

            // Finally create a STAN logical connection using the
            // NATS connection we just created.
            var connection = new StanConnectionFactory().CreateConnection("test-cluster", "test-client-001", stanOptions);
        }

@ColinSullivan1
Copy link
Member

I'm closing this issue; feel free to re-open if you continue to have issues.

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

No branches or pull requests

2 participants