nats.js should reconnect when one of nats servers are restarting
See original GitHub issueRun nats cluster:
Server A:
nats-server -p 4222 -cluster nats://localhost:4248 -routes nats://localhost:4248 -m 8222
Server B:
nats-server -p 5222 -cluster nats://localhost:5248 -routes nats://localhost:4248
Run nats-streaming-server in cluster mode:
nats-streaming-server -ns nats://0.0.0.0:4222 --cluster_id nats-streaming --clustered --cluster_bootstrap --cluster_node_id nats-streaming-1 --cluster_raft_logging --debug --dir store-b --store file
Go to examples and start it using yarn start
:
when it start and running try to kill cluster A
Actual results:
2020-08-25T00:47:14 ERROR NatsError: Could not connect to server: Error: connect ECONNREFUSED 127.0.0.1:4222
at Socket.<anonymous> (/Users/andrii/workspace/src/github.com/astronomer/houston-api/node_modules/nats/lib/nats.js:801:26)
at Socket.emit (events.js:315:20)
at Socket.EventEmitter.emit (domain.js:483:12)
at emitErrorNT (internal/streams/destroy.js:92:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
Expected results:
fallback to one of available nodes e.g. cluster B
P.S. golang client for nats works as expected:
go run main.go -s nats://127.0.0.1:4222 -t sub
Listening on [sub]
2020/08/25 02:17:22 Disconnected due to:EOF, will attempt reconnects for 10m
2020/08/25 02:17:22 Reconnected [nats://192.168.1.232:5222]
2020/08/25 02:17:37 Disconnected due to:EOF, will attempt reconnects for 10m
2020/08/25 02:17:37 Reconnected [nats://127.0.0.1:4222]
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Reconnect issues while server restarts #138 - nats-io/stan.js
When you get a notification on close , you have to re-initialize the STAN connection, there's no reconnection after a close event.
Read more >Set the Number of Reconnect Attempts - NATS Docs
After a successful reconnect to a server, the client will reset that server's failed reconnect attempt count. If a server was removed from...
Read more >NATS JetStream - ThinkMicroservices.com
If the consumer restarts, the server will continue at the last stream position. Pull subscriptions require a durable consumer. Its also ...
Read more >Nodejs Express API with NATS? - Stack Overflow
I have a nats-server running in my terminal. This is my test code: var express = require("express"); var app = ...
Read more >node-nats-streaming | Yarn - Package Manager
Stan.js - Node.js client for NATS Streaming. NATS Streaming Server is an extremely performant, lightweight reliable streaming platform powered by NATS.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Similar exercise to yours:
Excellent!