Slow consumer state still seems off, this is a first step trying to improve.
Increased the default number of pending messages limit but kept bytes the same.
Also introduced a default ErrHandler that will print out to stderr in case none has been set.
Signed-off-by: Derek Collison <derek@nats.io>
-Add ReconnectJitter option setter allowing user to set jitter
for non and TLS connections (possibly different values)
-Default for non-TLS will be 100ms and TLS 1sec
-Add a CustomReconnectDelay handler that is passed the number
of full url lists attempts. The user callback will then return
a duration that is going to be used for the wait. It is the
responsibility of the user to send a delay with some jitter
if desired.
Resolves#563
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
Replaced the use of sync.Once.Do() with a subscribe() version that
does not grab the lock (and assume to be running under the conn
lock).
Fixed some tests to reduce risk of go routine hanging at the end
of some tests.
Close the connection's asyncCBHandler even when close() is not
pushing disconnect/close CB.
Resolves#537
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
PR #523 introduced and issue that could cause a Request() call
to receive a reply that was intended for another Request() call
if the responder sent multiple replies for the same request.
This issue is only in v1.9.0
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
Currently, if you pass a path with a tilde to nats.UserCredentials it fails
because it doesn't expand the tilde to mean the user's home directory.
This change adds support to expand paths with a tilde, such as "~/.nkeys".
Move the detection/handling down to sendConnect when we know we
got an -ERR from the server. With the use of a boolean we know
if we should abort the reconnect attempts in the doReconnect loop.
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
In general we want to retry a connection that got an auth error whether its a violation or expiration. However we want to close the connection if we get the same error twice on same server.
Also replaced code now present in jwt lib.
Signed-off-by: Derek Collison <derek@nats.io>
Replaced to loopback ipv4 instead of localhost. In some cases,
when running the server with 127.0.0.1, if the application uses
the previous default URL (localhost), the library would resolve
this and possibly get 2 IPs (common to get 127.0.0.1 and ::1),
and it would then pick randomly one of those 2. If getting ::1,
and the server is listening on 127.0.0.1, the connection would
fail before it tries with the ipv4 address.
Also replaced reference of gnatsd with nats-server.
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
This returns the RemoteAddr().String() of the server the connection
is currently connected to.
That is, say server is running on loopback port 4222, this call
would return: "127.0.0.1:4222"
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
When a hostname is provided, before dialing we resolve the host
and get possibly several IPs. We randomize them before calling
net.Dial() so that we don't always connect to the same IP.
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
A permission error on a subject that would have upper case would
be converted to all lower case, which is not correct.
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>