question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't reconnect if the server was restarted

See original GitHub issue

Situation: Server v1.3, with authentication, client v2.1.0. Initialization code:

Options.Builder builder = new Options.Builder()
        .server(<...>)
        .userInfo(<...>,<...>)
        .maxReconnects(-1)
        .pingInterval(Duration.ofMillis(PING_INTERVAL_MS));
Options opts = builder.build();
Nats nats = Nats.connect(opts);

Old behavior (Nats v1.0.4, Jnats v1.0.0): Server started->client connects->client pushes messages->server restarted->client tries to reconnect->ok->client pushes messages.

New behavior: Server started->client connects->client pushes messages->server restarted->client tries to reconnect->gets error->can’t push.

Server log:

[27118] 2018/09/12 12:33:30.236462 [DBG] 127.0.0.1:47154 - cid:10 - Client connection created [27118] 2018/09/12 12:33:30.253822 [ERR] 127.0.0.1:47154 - cid:10 - Authorization Error - User “” [27118] 2018/09/12 12:33:30.253869 [TRC] 127.0.0.1:47154 - cid:10 - <<- [-ERR Authorization Violation] [27118] 2018/09/12 12:33:30.253895 [DBG] 127.0.0.1:47154 - cid:10 - Client connection closed

So, it seems that client relies on authentication cache and doesn’t send credentials again.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:14 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
sasburycommented, Sep 19, 2018

my fix provides a fast path for all the protocol messages until the reconnect process is complete. So all the subscriptions are set up before the protocol messages start using the same queue as the regular messages. This is definitely something that would be very hard to work around, but I think the changes in v2.1.1 (branch is there if you want to look), should fix the issue because they allow the connect, ping and subscribe to jump the queue.

0reactions
Imaskarcommented, Sep 19, 2018

I checked if I could hold publisher from reconnecting by waiting on a semaphore in event listener, but it didn’t work - reconnecting happens in another thread.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Server does not connect on restart - TechNet - Microsoft
1. Control panel – Program – Uninstall a program – View installed updates – uninstall Windows Server Essentials Connector. 2. Change the client ......
Read more >
Unable to connect after reboot - Windows Server
Try rejoining the server to the domain. You can go with the two step approach of dropping down to a workgroup, restart and...
Read more >
Cannot Connect to RDS Server after Server restart or Update
If you cannot connect to Remote Desktop Server (RDS) after Server restart or Windows Update, here are some troubleshooting steps you can ...
Read more >
Can't reconnect to a server after leaving it unless you restart it?
When I launch TerrariaServer.exe everything works and all my friends can join. However, once someone (anyone) leaves, you get stuck on ...
Read more >
How to Fix Windows VPN Connecting Only after a Restart
If this method is not working for you (you're still unable to re-connect to your VPN without restarting), move down to the next...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found