mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-02 11:48:43 -07:00
The RunServer() function (and the various variants) call Server.Start() in a go-routine, but do not return until it has verified that the server is ready to accept connections. To do so, it use GetListenEndpoint() to get a suitable connect address (replacing "0.0.0.0" or "::" with localhost - important on Windows). It then creates a raw TCP connection to ensure the server is started, repeating the process in case of failure up to 10 seconds. This PR replaces this with a function that checks that client listener, and route listener if configured, are set. This removes the need to get a connect address and create test tcp connections. The reason for this change is that NATS Streaming when starting the NATS Server (unless configured to connect to a remote one) calls RunServerWithAuth(), which when getting "localhost" from GetListenEndpoint(), would fail trying to resolve it. This happened for the NATS Streaming Docker image built with Go 1.7+.