Somehow when it was ported to .NET Core, the transition from connecting to connected was switched to being done before the connect rather than after. As a result, if the connection fails and the websocket is never initialized, subsequent use (misuse) ends up null ref'ing. This restores the .NET Framework behavior, which was to dispose of the instance if the connect fails; subsequent operations then throw ObjectDisposedException.
Get rid of StreamWriter usage in HTTP loopback server and fix HTTP/1.1 loopback implementation of SendResponseBodyAsync
Co-authored-by: Geoffrey Kizer <[email protected]>
* [browser][websocket] Fix for Close Description validation
- Issue https://github.com/dotnet/runtime/issues/45531
- The description validation exception was not being percolated through to the unit test
* Remove test code
* Address review comments. Wrap in a try/catch that will catch that exception and store it into a task to be returned.
* Fix merge conflict
* Remove active issue
Co-authored-by: Larry Ewing <[email protected]>
* [browser][tests][outerloop] Standup OuterLoop tests
* Reference issue not PR
* Add active issue for CloseDescription failing tests
* Add active issue for failures for invalid close codes failing tests
* Add active issue for failures when specifying subprotocol by URI Query
* Add active issue for Uncaught RuntimeError: memory access out of bounds
* Remove ActiveIssue and initialize with specific platform detection code
- Removes the necessity of setting up a new test.
- May want to go back to ActiveIssue for tracking purposes.
* Add ActiveIssue for CloseOutputAsync
* Add ActiveIssue for AbortTests
* Remove ActiveIssue and initialize with specific platform detection code
- Removes the necessity of setting up a new test.
- May want to go back to ActiveIssue for tracking purposes.
* Remove Active issue as it was fixed.
* Add ActiveIssue for CancelTests that is part of the Abort tests changes
* Update src/libraries/System.Net.WebSockets.Client/tests/ClientWebSocketOptionsTests.cs
Point to WebProxy support issue
Co-authored-by: Larry Ewing <[email protected]>
* [browser][websocket] Throw OperationCanceledException on connect if cancel was requested before.
* try to handle cancellation in connect stage
* Add new test for inflight connect
- Add new supported property for skipping particular tests when Browser is detected and DOM is detected.
* first pass at throwing pnse when websocket is missing
* Address review comment
* Make the platform check explicit
* Revert CreateDefaultOptions change
* Address review comment
Co-authored-by: Larry Ewing <[email protected]>
* [browser][tests] Standup System.Net.WebSockets.Client.Tests in CI
* Just a small test to see if tests are actually kicked off and failing.
* Remove comment from ActiveIssue to pass tests
* Address review comments
- mark the loopback issues as activeIssue - [ActiveIssue("https://github.com/dotnet/runtime/issues/34690", TestPlatforms.Browser)]
* Address review comments
* Correct confusion I caused
* Remove extra extra exclusion that snuck in
* Make browser specific failure browser specific
Co-authored-by: Larry Ewing <[email protected]>
* Mark System.Net.WebSockets.ClientWebSocketOptions APIs as unsupported on Browser
* Add the attributes to non-browser version of ClientWebSocketOptions class to avoid build error
* Add using
* Include platform attributes
- Remove depprojs which currently binplace external references into the RefPath folders in favor of PackageReference and PackageDownload items.
- Build all configurations by default when building an individual project (either on the CLI or inside VS) same as with the official SDK. This enables .NETFramework Test Explorer support.
- Centrally define libraries that compose the shared framework instead of in each Directory.Build.props file to be able to build the targeting pack first and consume it in the OOB libraries.
- Use ProjectReferences to reference OOB projects. Compile against the reference assembly but use the implementation assembly app-local during runtime.
- Remove OOBs from the testhost and remove the testhost folder for .NETFramework as it isn't required anymore.
- Only binplace for $(NetCoreAppCurrent) to compose a) the targeting pack, b) the runtime pack, c) the testhost, d) a full closure for the shims.
- Use Targeting Packs for OOB projects (with their implicit assembly references) but still explicitly define granular references for .NETCoreApp configurations (DisableImplicitAssemblyReferences switch). Use the implicit targeting pack references in some Microsoft.Extensions.* cases.
- Remove placeholder configurations as they aren't needed anymore with explicit P2Ps vs Targeting Pack references.
- Remove implicit assembly references (ie for .NETFramework, mscorlib)
- Remove AssemblySearchPath hacks that were introduced with b7c4cb7 as the targeting pack is now used by default.
- Reduce unnecessary .NETFramework configurations that were added to run tests in favor of the already existing ref&src configurations.
- Stop hardcoding the paths for wasm assemblies and use the returned TargetPath of the ProjectReferences.
- Addressed formatting (ItemGroups, References at the bottom of the project file, ordering of references, use LibrariesProjectRoot instead of a relative path, unnecessary AssemblyName and RootNamespace properties which are identical to the project name, ordering of tfms)
- Revert "fix clean (#33758)"
It's raising a single event for failed connects, and actual networking-related failures for failed connects will already be logged by the underlying API used.
By getting rid of the catch and rethrow, we can also avoid an extra layer of async state machine on connect.
* [browser][wasm] Initial addition of WebSockets support
* Clean up usings
* Create and use a WebSocketHandle.Browser.cs module
* Add conditional TARGETS_BROWSER so as not to throw Proxy PNSE during ClientWebSocket creation.
* Update WebSockets code
* Removing debug line
* Remove `ThrowIfReadOnly` method to address review comments
* Address review comments
- change accessor of _requestedSubProtocols to private
- condition more code in WebSocketHandle.Managed.cs to not access _requestedSubProtocols
* Address review comments
* Address review comments
* Change to be PlatformNotSupportedException
* Add ConnectAsync implementation to create a new instance of the BrowserWebSocket implementation.
* Address review comments
* Address subprotocols comments
* Remove internal custom class ActionQueue class in favor of using a Channel.
* Fix object leak.
- Lambdas are not being released automatically.
* Add doc for the constant that is being used.
- Address review comment
* Clean up SendAsync method.
- Validate the message type.
- Validate the array segment that is passed as the message.
* Add validation to ReceiveAsync for invalid buffer.
- remove unnecessary null checks from message buffering.
* Address review comments
* Address review comments about TCS
* Address camel case by using enum
* Address abort request
* Handle nullable
* Address review comment for removing cancellationtoken registration to the connect source.
* Use non-generic TaskCompletionSource
* Cleanup var usage
* Add string to .resx
* Inline dispose
* Fix WebSocket opening exception
* Remove the asynchronous completion from SendAsync.
* Fix object leak, exception on close and address review comments
* Handle race condition
* Address TaskCompletionSource on connect review comments
* Update src/libraries/System.Net.WebSockets.Client/src/System/Net/WebSockets/BrowserWebSockets/BrowserWebSocket.cs
Co-authored-by: campersau <[email protected]>
* Update src/libraries/System.Net.WebSockets.Client/src/System/Net/WebSockets/BrowserWebSockets/BrowserWebSocket.cs
Co-authored-by: campersau <[email protected]>
* Fix Connect not completing task on error.
* Cleanup reference
* Remove redundant error check of memorystream buffer.
* cleanup
* Update src/libraries/System.Net.WebSockets.Client/src/System.Net.WebSockets.Client.csproj
Co-authored-by: Maxim Lipnin <[email protected]>
* Update src/libraries/System.Net.WebSockets.Client/src/System.Net.WebSockets.Client.csproj
Co-authored-by: Maxim Lipnin <[email protected]>
* Update src/libraries/System.Net.WebSockets.Client/src/System.Net.WebSockets.Client.csproj
Co-authored-by: Maxim Lipnin <[email protected]>
* Update src/libraries/System.Net.WebSockets.Client/src/System.Net.WebSockets.Client.csproj
Co-authored-by: Maxim Lipnin <[email protected]>
* Fix typo
* clean up buffer code
* Modify callbacks to use lambda function.
- These are now released properly after reference counting went in.
* Fix object leak of delegate and clean up deprecated code.
* extract lambda into method
* Update src/libraries/System.Net.WebSockets.Client/src/System/Net/WebSockets/BrowserWebSockets/BrowserWebSocket.cs
Co-authored-by: Stephen Toub <[email protected]>
* Update src/libraries/System.Net.WebSockets.Client/src/System/Net/WebSockets/BrowserWebSockets/BrowserWebSocket.cs
Co-authored-by: Stephen Toub <[email protected]>
* Update src/libraries/System.Net.WebSockets.Client/src/System/Net/WebSockets/BrowserWebSockets/BrowserWebSocket.cs
Co-authored-by: Stephen Toub <[email protected]>
* Review comments addressed
Co-authored-by: campersau <[email protected]>
Co-authored-by: Maxim Lipnin <[email protected]>
Co-authored-by: Stephen Toub <[email protected]>
For the non-generic IEnumerator, we don't have any idea whether the type contains nulls or not. If we're forced to annotate it, `?` is correct, because it says "it's possible this is null" and we can't prove it's not. But that ends up leading to lots of spurious warnings, in particular when enumerating over supplied collections that won't ever contain null, e.g. enumerating a CookieCollection. Since the non-generic IEnumerator is effectively legacy, our best path forward while maintaining correctness and avoiding causing unnecessary warnings is to simply not annotate `IEnumerator.Current` at all, leaving it "oblivious"; in that way, we don't make any claims about its state, and leave it up to tooling how to best convey that.
- Adds the type, almost an exact copy of `TaskCompletionSource<TResult>`, but creating a `Task` instead of a `Task<TResult>`. Primary benefits here are symmetry, smaller `Task` object, and not forcing a developer to specify an unnecessary type name.
- Adds tests for both TCS and TCS<TResult>.
- Switches a bunch of usage of the generic type over to the non-generic, both in src and tests.
We allow at most one pending receive operation on a web socket, and CloseAsync needs to both send and receive, so if there's a pending receive already, it just reuses / waits for that existing one, which records if it sees a close frame. However, if the close operation is initiated with a cancellation token that's different from the cancellation token the receive operation was initiated with, the close won't respect the supplied cancellation token because it's just waiting on the existing receive. The fix is simply to register with this new cancellation token as well when there's an existing receive that we wait on.
CloseOutputAsync_Cancel_Success tests are failing due to 2 reasons:
1. `Assert` expecting the state to be `Aborted`, finds it's `Open` - most frequent
2. Connection gets forcibly terminated on a connect attempt
However, the second failure type is not specific to this test because it affects many tests in different types during the same time. Thus, it seems to be an infra issue.
This PR fixes only the first failure type by increasing Close operation timeout.
Fixes#1725
Changes:
- enabled `runtime (Libraries Test Run release mono Windows_NT x64 Debug)` CI lane (Windows Nano Server CI leg is disabled);
- enabled the tests that pass;
- marked failing test assemblies/classes/methods with `ActiveIssue` attribute using respective GH issues;
- removed CoreFX.issues_windows.rsp file and related mono rsp arguments.
Fixes#1980
* libraries -restore for vertical build without test restore
* Automatic test change and regex to remove the addition of an extra line at eof
* manual test restore fixed (restore completely done for vertical build)
* build native done
* Automatic ref change and regex to remove the last line
* manual reference assebly change and generated shims build
* automatic src change and regex
* native bin place and src build manual change
* apicompat and pretest.csproj done
* fixing the package build
* fixing all config
* packaging and feedback
* adding back placeholder configuration
* fixing the shims
* delete configuration.props
* making the build work in master
* Test Change
* fixing the packageing, test restore replacing TargetFramework -> OriginalTargetFramework
* delete test configuraiton.props, trailing semicolon and use targetFramework
* reverting the package change
* enable apicompat and fixing configurationGroup for individual projects
* fixing the api compat
* making ilproj work
* adding the outerBuildTest
* adding the arcade package version
* fixing the merge conflicts
* minor changes
* adding additional configs and setting the runtimeOS
* making the vs stuff work
* removing the target Group to fix the apicompat
* fixing the linux build and some minor changes
* making additionalBuildTargetFramework LOcalProperty
* fixing the allConfigurations build
* fixing the netfx build
* fixing package Testing and restore
* Missing TargetFrameworks tag
* making the VSdesgin stuff work
* Remove OriginalFramework Entirely
* some minor pr feedback
* RemoveExtraSemicolon
* use boolean exclude flag
* fixing yml scripts to pass tests
* adding comments and some minor feedback
* moving packaging property to correct plave
* fixing the build for web assembly
* Fixing the live ci build
* Fixing the live build for shims
* fixing the tests
* fixing the packaging and enterprise linux
* fixing package sizes
* Fix the targetFramework
* updating the targetFramework sdl
* removing the buildOS and be able to use OSGroup as done in the old system
* Fixing the osgroup stuff for send to helix task
* Fix OSX failures
* Fixing the osx build
* uploading tmp folder to artifacts
* running restore for runtime.deproj correctly
- In some cases, I deleted ActiveIssues associated with issues where the problem was supposedly fixed. We'll see.
- In some cases, I deleted test cases entirely, e.g. where the corresponding issue said effectively "we'll live with the behavior" or "another repo is responsible for this now" (paraphrasing), or where the tests were initially added to the repo years ago already disabled and against bug numbers from some old bug database.
- In some cases, I replaced the link with the correct one.
- In some cases, I re-opened closed issues.
* Address more issue numbers in the code
Replaced a bunch of unadorned issue numbers with links, so we know which repo the issue is for. In some cases the repo was named, but for consistency I still replaced it with a link.
In some cases, in particular where the issue had been closed saying effectively "we're not going to do anything here", I removed TODOs and the associated issue numbers.
In a few cases, the TODO and issue number was to say "we should do X when Y is fixed", so I did X since Y was fixed.
* Apply suggestions from code review
Co-Authored-By: Jan Kotas <[email protected]>
* Address PR feedback
* Fix OrderedEnumerable by using MemoryExtensions.Sort
Co-authored-by: Jan Kotas <[email protected]>
Disables `ConnectAsync_NotWebSocketServer_ThrowsWebSocketExceptionWithMessage`
as it's consistently failing in the outerloop jobs. Specifically the
libraries linux outerloop job.
Tracking Issue is #1895
* netcoreapp -> netcoreapp5.0 in .sln files
* netcoreapp; -> netcoreapp5.0; , netcoreapp- to netcoreapp5.0-
* netcoreapp- -> netcoreapp5.0 in .csproj
* 'netcoreapp -> 'netcoreapp5.0 in .csproj
* done with libraries sub folder
* missed semicolon
* minor changes
* netcoreapp -> netcoreapp5.0 in some extra files
* vNext target variable in configurations.props
* netcoreapp => netcoreapp5/0 in some other .props file
* netcoreapp -> vnext in .csproj
* making the netcorepap framework switch work
* fixing sendToHelix and linux build
* TargetFrameworkVNext -> netcoreappCurrent
* case correct netcoreappcurrent
* fixing send to helix zip path
* netfx -> net472 in .sln
* netfx; -> net472; in .props
* netfx- -> net472- in .props
* netfx - -> net472- in .csproj
* 'netfx-> 'net472 in .csproj
* netfx -> net472 manual change
* fixing ci build for netfx
* Not trying to change the global property
* Fixing build failure due to master changes in net https tests
* adding documentaiton and fixing filtering
* netcoreapp -> netcore5.0 in py file
* changing the path to use netcoreapp5.0 version
* feedback and override corefx path corrected in installers
* remaing netcoreapp5.0 changes done
* netcoreapp-> netcoreapp5.0 after live builds
* net472 -> netframeworkcurrent
* Fix test build break and update common path usages to use property
* Use normalize directory for CommonPath and CommonTestPath
* Update instances of CommonPath and CommonTestPath to not use trailing \
Many of our RemoteInvokes are there purely because of needing to change the current thread culture but on UAP that actually impacting the whole process. Until that's addressed, we can at least avoid the RemoteInvoke on all platforms other than UAP. There are also some RemoteInvokes that can be avoided by just serializing all of the (small number of) tests in a test assembly. And there's some additional cleanup to be done as well around not explicitly returning an exit code unless required.
This helps measurably with test performance. Consider the System.ComponentModel.Annotations test suite. On my machine, prior to these changes, it took ~25 seconds; after these changes, it takes ~0.3. It helps even more when running against a checked runtime, where all of our test costs are magnified. With a checked runtime, prior to these changes, it takes ~196 seconds; after these changes, it takes ~2.5 seconds. This should help measurably with CI time in coreclr.
Commit migrated from https://github.com/dotnet/corefx/commit/cd18bafbabf7fe47601f6f790d157409034a2477