Commit Graph

122 Commits

Author SHA1 Message Date
Derek Collison
60de70431f JetStream API updates
Signed-off-by: Derek Collison <derek@nats.io>
2020-11-30 06:46:23 -08:00
R.I.Pienaar
93be3c8e71 Merge pull request #609 from ripienaar/606
ensure response message goes to the reply subject in RespondMsg
2020-11-16 18:04:59 +01:00
R.I.Pienaar
41eef2a5be ensure response message goes to the reply subject in RespondMsg
Signed-off-by: R.I.Pienaar <rip@devco.net>
2020-11-16 15:52:39 +01:00
Derek Collison
b9917b8e17 Changes to default pending and default error handler.
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>
2020-11-15 11:06:26 -08:00
R.I.Pienaar
1044b72a6b expose additional info line information to the client
Signed-off-by: R.I.Pienaar <rip@devco.net>
2020-11-11 16:12:03 +01:00
Derek Collison
643f27b895 Check description in test
Signed-off-by: Derek Collison <derek@nats.io>
2020-10-21 07:27:11 -07:00
Derek Collison
7ce305ab0b Add support for status line plus description
Signed-off-by: Derek Collison <derek@nats.io>
2020-10-20 17:30:41 -07:00
R.I.Pienaar
8c8e1e9644 remove DeliverySubject from the public ConsumerConfig
Signed-off-by: R.I.Pienaar <rip@devco.net>
2020-10-12 10:43:57 +02:00
R.I.Pienaar
a08c0a0959 unexport various things copied from jsm
Signed-off-by: R.I.Pienaar <rip@devco.net>
2020-10-12 10:43:57 +02:00
R.I.Pienaar
8b08268553 Allow the Subscribe functions to access JetStream consumers
Signed-off-by: R.I.Pienaar <rip@devco.net>
2020-10-08 10:30:10 +02:00
Matthias Hanel
5c3369f827 Removing dependency on jwt
Signed-off-by: Matthias Hanel <mh@synadia.com>
2020-06-01 13:59:23 -04:00
Matthias Hanel
73e0d83dd9 Picking up jwt2 branch of jwt and nats-server 2020-06-01 12:57:04 -04:00
Ivan Kozlovic
8fb3769283 [ADDED] LameDuckModeHandler option/setter
This will be invoked when the server enters LDM mode.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2020-05-29 09:47:33 -06:00
Derek Collison
974ef22aa1 Cleanup header decoding
Signed-off-by: Derek Collison <derek@nats.io>
2020-05-27 23:03:28 -07:00
Ivan Kozlovic
1b0a85aad4 Merge pull request #564 from nats-io/fix_563
[FIXED] Added jitter in the reconnect logic
2020-05-13 16:32:39 -06:00
Ivan Kozlovic
1b2a2d61c7 Shuffle but leave first URL in place
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2020-05-06 15:34:22 -06:00
Ivan Kozlovic
a5c7af3ad8 [FIXED] Randomize discovered server URLs if allowed
After adding discovered URLs from the INFO, reshuffle the pool
if option allows

Resolves #565

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2020-05-06 11:24:23 -06:00
Ivan Kozlovic
2431048550 [FIXED] Added jitter in the reconnect logic
-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>
2020-05-06 09:07:05 -06:00
Derek Collison
661cce1e84 Added in support for client IP from the server and RTT calculation
Signed-off-by: Derek Collison <derek@nats.io>
2020-04-26 14:09:28 -07:00
kirill256
94f87c60de Update nats_test.go 2020-04-07 10:29:42 +03:00
Ivan Kozlovic
409e5b8057 [FIXED] Do not use sync.Once.Do() in connection's first request init
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>
2020-01-07 14:55:21 -07:00
Derek Collison
dcd457d195 PubSub from same connection was contending on lock checking closed state.
Signed-off-by: Derek Collison <derek@nats.io>
2019-11-12 09:45:16 -08:00
Ivan Kozlovic
a3c7525567 [FIXED] Request() may receive invalid reply if reponser send multiples
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>
2019-10-31 17:25:16 -06:00
Ivan Kozlovic
6635d2e7e6 Release v1.9.0
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2019-10-30 11:22:50 -06:00
Derek Collison
d5ed91cb92 Simplify request, allow for mux subject to change
Signed-off-by: Derek Collison <derek@nats.io>
2019-10-08 14:56:32 -07:00
Ivan Kozlovic
b4437f154b [FIXED] Data race between processMsg() and Stats()
Resolves #520

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2019-09-17 09:07:18 -06:00
Jaime Piña
6ffcfbcbf0 Expand paths with tilde (#512)
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".
2019-08-29 18:27:43 -07:00
Ivan Kozlovic
0b788930ce Rework auth errors handling during reconnect
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>
2019-08-07 11:29:26 -06:00
Ivan Kozlovic
abce8178f2 Trim "nats: " before invoking processErr in doReconnect
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2019-08-06 10:59:14 -06:00
Derek Collison
6a4eb62319 processErr inline for reconnect
Signed-off-by: Derek Collison <derek@nats.io>
2019-08-04 09:01:43 -07:00
Derek Collison
1a04abe03e Clear lastErr on reconnect success
Signed-off-by: Derek Collison <derek@nats.io>
2019-08-03 07:30:12 -07:00
Derek Collison
d59505c35d Merge pull request #499 from nats-io/expired
Handle expiration and auth errors on reconnects.
2019-07-31 12:03:43 -04:00
Derek Collison
e2a5163380 Make sure we expire after multiple failures
Signed-off-by: Derek Collison <derek@nats.io>
2019-07-31 11:55:17 -04:00
Derek Collison
2535197ca4 Check bad subjects and queues on subscribe, fixes #84
Signed-off-by: Derek Collison <derek@nats.io>
2019-07-31 11:48:12 -04:00
Derek Collison
42ba648f97 Handle expiration and auth errors on reconnects.
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>
2019-07-31 11:15:38 -04:00
Ivan Kozlovic
2a61c1885f Fixed nats-server import paths
Otherwise, projects pulling nats.go end-up with issues.

Resovles #478

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2019-06-04 08:42:30 -06:00
Ivan Kozlovic
c1c3d60e59 Prepare for next release
Use lint directives for staticcheck to work

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2019-05-30 11:07:21 -06:00
Maxim Korolyov
39ee2f28a7 fixes #454. Added DisconnectedErrCB to client 2019-05-15 00:03:22 +03:00
Derek Collison
234e9d8119 Updates for rename and go.mod support
Signed-off-by: Derek Collison <derek@nats.io>
2019-05-10 13:24:55 -07:00
Ivan Kozlovic
8df1cb3fa9 [CHANGED] DefaultURL changed to "nats://127.0.0.1:4222"
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>
2019-05-09 18:08:28 -06:00
Derek Collison
23a0279357 Fix for race on sub sync type setting, https://github.com/google/go-cloud/issues/1556
Signed-off-by: Derek Collison <derek@nats.io>
2019-03-14 12:50:33 -07:00
Derek Collison
609b485fdd Fix for bad TLS error on bad credentials/auth
Signed-off-by: Derek Collison <derek@nats.io>
2019-03-13 16:17:36 -07:00
Derek Collison
7af04a4c29 Properly randomize multiple addrs for single host.
We were using range but range seems to not be random from a distriution standpoint.

Signed-off-by: Derek Collison <derek@nats.io>
2019-03-06 08:43:17 -06:00
Derek Collison
9b7fc5fe4b Improve NextMsg() performance when msg available
Signed-off-by: Derek Collison <derek@nats.io>
2019-02-21 11:53:04 -08:00
Ivan Kozlovic
e37cb12015 [ADDED] Conn.ConnectedAddr()
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>
2019-01-16 19:43:00 -07:00
Ivan Kozlovic
85342700ff [FIXED] Randomize IPs result from LookupHost before creating connection
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>
2018-12-14 15:26:44 -07:00
Ivan Kozlovic
c54577a777 [FIXED] Maintain string case in errors
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>
2018-12-13 11:35:34 -08:00
Derek Collison
51e211806d Updates for jwt and server changes
Signed-off-by: Derek Collison <derek@nats.io>
2018-12-05 20:55:57 -08:00
Derek Collison
cee48fc43d Updated test credentials
Signed-off-by: Derek Collison <derek@nats.io>
2018-11-29 17:52:37 -08:00
Derek Collison
f7e6452e61 Save *srv instead of just url for current
Signed-off-by: Derek Collison <derek@nats.io>
2018-11-25 05:40:49 -08:00