-
-
Notifications
You must be signed in to change notification settings - Fork 932
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
Optimize AppVeyor network stack for number of dynamic connections #922
base: develop
Are you sure you want to change the base?
Conversation
appveyor.yml
Outdated
@@ -1,5 +1,9 @@ | |||
os: Visual Studio 2019 | |||
|
|||
init: | |||
- netsh int ipv4 set dynamicport tcp start=1025 num=64510 | |||
- powershell "New-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters' -Name 'TcpTimedWaitDelay' -Value '15' -PropertyType 'DWord'" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This setting requires this other key to be set or it will have no effect: (Source)
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters]
"StrictTimeWaitSeqCheck"=dword:00000001
It also only takes effect after reboot, so if the AppVeyor VM reverts to base settings on each reboot this will also have no effect.
Third, both commands require Elevation. Does AppVeyor execute this as Admin? I find it unlikely.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, AppVeyor build VM is started fresh from image. So there is no point in setting this registry setting... do you know of any other method for setting wait delay that would be effective immediately?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we can set the per-socket timeout when running the test Suite?
// sets the amount of time to linger after closing, using the LingerOption public property.
LingerOption lingerOption = new LingerOption (true, 10);
SO_REUSEPORT or SO_REUSEADDR seem to be more appropriate, but it looks like Windows doesn't really care about these flags.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, this would work. But I think this amount of changes is beyond this PR and should be discussed further. For now I'll just remove the wait delay change as is is ineffective and leave the enlargement of client port pool in this PR.
Many internet sources indicate that the root cause for
System.Net.Sockets.SocketException: Only one usage of each socket address (protocol/network address/port) is normally permitted.
is port exhaustion. In case of SSH.NET tests, this could be caused by a large number of connections opened and closed in quick succession. This was already discussed in #877 (comment).In this PR I have both increased the number of ports that can be used for client side connections and decreased the time that the network stack needs to wait before reusing bindings. More information on these settings here.
As this only affects the AppVeyor build VM, I do not expect any regressions or side effects.
This will (hopefully) fix #921.