-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Consider not using the wall clock time for timeouts in Kestrel #13628
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Do you know if Stopwatch is actually guaranteed to be monotonic and continuous? |
My read on the documentation is that Stopwatch uses a monotonic counter as a backing store and looking through the code, that claim is backed:
I think the only time when it was not guaranteed is the pre-XP operating systems. |
If we change this is SignalR, we should probably consider doing the same for Kestrel timeouts. While it's probably not as likely to run on client devices with unreliable clocks like SignalR, it seems like the right thing to do. |
This specific case looks like the server was running on one of those devices so Kestrel would definitely have similar issues. |
Maybe Environment.TickCount or Environment.TickCount64 are good (and fast) enough? |
This is probably worth synchronizing with: dotnet/runtime#15207 |
Related to dotnet/corefx#35401 |
Related to that dotnet/corefx@06f25ea where they switched to the new Seems like a good possible mechanism to switch to. |
Thanks for contacting us. |
This feels like something we should do. |
Agreed, SignalR and Kestrel should switch to using |
The analogue for this in the SignalR JS/TS client is performance.now(). |
Updated the title since the SignalR side of this is done in #34382 |
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process. |
😢 I should push a branch for the Kestrel stuff I tried |
Sure, and I'm not ruling this out for 7. Just moved it out of NSP since it's too late for 6. |
This isn't an API change. I see no reason we couldn't take this for 6 if it's ready. |
Agreed. It's not ready though, and it sounds like it's trickier than originally imagined. @BrennanConroy if you are still interested in getting it done for 6, don't let the milestone change stop you :). |
Is your feature request related to a problem? Please describe.
I have an embedded instrument with an RTC that's powered by a small gold cap. However, that battery is limited and so the instrument might forget the current date / time. If that happens, the system boots with a default date/time depending on when the Linux image was built.
There's a user interface that's rendered on an internal web browser connected to the localhost web server via SignalR.
Third, there's a way to set the date/time when lost, which directly sets the wall clock on the instrument (the time difference is typically O(months)).
When the user sets the date/time, the SignalR connection runs into a timeout because timeouts are based on wall clock time and my thought-to-be stable localhost connection breaks. I have included a retry logic just for that case.
Describe the solution you'd like
Using wall clock for timeouts always runs into scenarios such as the one described above. In my opinion it would be better to base those decisions off of a monotonic and continuous time source (Stopwatch?).
The text was updated successfully, but these errors were encountered: