Timeout not working as expected
See original GitHub issueI’m doing some testing on failure scenarios, and am testing what happens if the NATS server is stopped while my process is running.
I’m finding the timeout periods seem to be getting ignored, assuming I’ve configured it correctly.
Here is my reproduce code.
using NATS.Client;
using System;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
namespace TestNats
{
class Program
{
static void Main(string[] args)
{
Task.Run(() => Run());
Console.ReadLine();
}
static async Task Run()
{
Console.WriteLine("Hello World!");
var cf = new ConnectionFactory();
var opts = ConnectionFactory.GetDefaultOptions();
opts.Timeout = 1000;
opts.AllowReconnect = false;
var conn = cf.CreateConnection(opts);
conn.SubscribeAsync("test", (p, a) => conn.Publish(a.Message.Reply, new byte[0]));
await conn.RequestAsync("test", new byte[0], 1000);
Console.WriteLine("Now stop nats server, you have 5 seconds");
Thread.Sleep(5000);
var s = new Stopwatch();
s.Start();
try
{
await conn.RequestAsync("test", new byte[0], 1000);
s.Stop();
Console.WriteLine(s.ElapsedMilliseconds / 1000 + "s");
}
catch (Exception ex)
{
s.Stop();
Console.WriteLine(s.ElapsedMilliseconds / 1000 + "s");
Console.WriteLine(ex.Message);
}
}
}
}
Output:
Hello World!
Now stop nats server, you have 5 seconds
60s
Timeout occurred.
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
javascript - Timeout is not working as expected
In this code i'm trying to print Timeout in console after 0.5 second, and there is a while loop which terminates after a...
Read more >Wait timeout and waitproperty not working as expected
I pass in two arguments the object and an integer value of how long I want it to wait for the exists property...
Read more >Idle timeout not working as expected. - Claris Community
What I've tried: 1. Set the "fmreauthenticate60" to 60 minutes and made sure there were no other fmreauthenticate's set to the privilege set....
Read more >HD72535: PART: TIMEOUT NOT WORKING AS EXPECTED
PART: TIMEOUT NOT WORKING AS EXPECTED Scenario: 1. start CATIA by using CNEXT ?workbench empty 2. CATIA will be started without product window...
Read more >Timeout does not work in expect script
I would explicitly expect the timeout: set timeout 10 spawn vpnc expect : send [lindex $argv 0]\r expect { timeout {error "incorrect ...
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
@ColinSullivan1 no problem - and thank for the quick response too.
I’ve tested your PR and it is giving the following output for my sample code.
This seems good to me. Thanks for your help!
@chrismcv, Great - thank you for testing! My local tests pass as well; I’ll merge the PR.