Commit Graph
226 Commits
Author SHA1 Message Date
Stephen Toub a46d154e4b Merge pull request dotnet/corefx#9565 from stephentoub/ws_refactoring
Several more WebSocket tweaks

Commit migrated from https://github.com/dotnet/corefx/commit/cded4394fee8bbfaad624e2e1816bf3c9c72207f
2016-06-21 14:31:35 -04:00
dotnet-bot 4609395f97 Updating CoreFx dependencies to beta-24221-03
Commit migrated from https://github.com/dotnet/corefx/commit/6e72d3c127cae0a175c63dc942b8c7d8ac5da38b
2016-06-21 13:14:17 +00:00
dotnet-bot a4819aef80 Updating CoreFx dependencies to beta-24221-02
Commit migrated from https://github.com/dotnet/corefx/commit/818ad5af9340661114d112e6f7d511e380bc4f81
2016-06-21 07:17:46 +00:00
Matt Galbraith 1a00d4e5b6 Update references to Microsoft.DotNet.BuildTools.TestSuite to a version that understands uap10.0, add version validation rule for same.
Update reference to Xunit.Console.Netcore to pick up new version which does not throw if Console Color APIs do.


Commit migrated from https://github.com/dotnet/corefx/commit/91260ea102e681b16864596f0b9b2f14d3be82be
2016-06-20 16:49:13 -07:00
Stephen Toub 9bc5a4d23b Delete now dead code
Commit migrated from https://github.com/dotnet/corefx/commit/107ee39aadfef438779d8de382fd95756e18d7a1
2016-06-20 17:03:27 -04:00
Stephen Toub 8535116885 Handle more bad protocol cases
These weren't flagged by the test suite, but they better match the spec.


Commit migrated from https://github.com/dotnet/corefx/commit/028b5807d9de87652847956f24d52ed76cd70db5
2016-06-20 16:56:37 -04:00
Stephen Toub 289956f406 Capture exception from send method into returned task
Rather than allowing it to escape synchronously from the method.


Commit migrated from https://github.com/dotnet/corefx/commit/f1a6ea4ef8dbf61f840c247fba2bb2d481e25bdc
2016-06-20 16:06:34 -04:00
Stephen Toub 748ebc3d12 Small refactorings/fixes in WebSockets managed client
- Separate handling of close and ping/pong messages into their own functions.  This helps to keep the main receive function a bit more streamlined, and helping with the more common case we care to optimize for, sending and receiving.
- Remove two locals from the receive async function; this shrinks the size of that async state machine when yielding by a few bytes.


Commit migrated from https://github.com/dotnet/corefx/commit/ef8fd9e532190dff3d6c343e40b8b0fba5684217
2016-06-20 16:05:50 -04:00
Eric StJohn 63fa7de08b Merge pull request dotnet/corefx#9524 from ericstj/Update-beta-24217-04
Update CoreFx packages  to beta-24217-04

Commit migrated from https://github.com/dotnet/corefx/commit/2c42a8f7b759f5f3973a05e7abf54144bba6702d
2016-06-20 09:22:44 -07:00
Stephen Toub c169c2419f Add retry to GetConnectedWebSocket
To hopefully avoid spurious failures when connecting to the Azure endpoint.


Commit migrated from https://github.com/dotnet/corefx/commit/13512b795e811b10f2deac1e8af2632fe0e10853
2016-06-19 20:41:18 -04:00
Stephen Toub 4db5fc183b Several managed WebSockets tweaks
- When we fail to connect due to a abort/cancellation, ensure the inner exception of the WebSocketException is an OperationCanceledException rather than an ObjectDisposedException.
- When sending a keep-alive ping, if the send lock is already held, that means we're actively sending something, so there's no value in also sending a keep-alive; we can simply make it a nop.
- Only create the keep-alive timer if asked for.
- Make a field readonly.
- Ensure that we propagate exceptions as inner exceptions whenever possible


Commit migrated from https://github.com/dotnet/corefx/commit/9257f10f0cb457ad161144ddc757cda2450b627f
2016-06-18 23:16:15 -04:00
Eric St. John 01ee645e45 Update CoreFx packages to beta-24217-04
Commit migrated from https://github.com/dotnet/corefx/commit/35ee6b6688b57d0b445a252160a922404c35af5e
2016-06-17 15:01:55 -07:00
Eric St. John 45ad837e55 Build product assemblies against stable packages
I'm leaving tests compiling against pre-release.  Once we have a
new build of "beta" packages we'll need to update tests to those
versions.


Commit migrated from https://github.com/dotnet/corefx/commit/7cf5bb608f8da26730bdaf8864b2ddb68735cb38
2016-06-16 16:03:54 -07:00
Eric St. John 3b1d041ed2 Bump versions across corefx and move to beta
Now that we have stable packages for our current versions we need to
bump the 3rd portion (bugfix) to represent code-changes without API
additions.


Commit migrated from https://github.com/dotnet/corefx/commit/92a411776004239482ba1b5032afc8483518810c
2016-06-16 16:03:53 -07:00
Stephen Toub 0568649dc9 Merge pull request dotnet/corefx#9436 from stephentoub/websocket_testtime
Significantly reduce running time of WebSocket.Client tests

Commit migrated from https://github.com/dotnet/corefx/commit/f65ced2f2e8f77a4f9b9d916767660c7dda11fa5
2016-06-15 18:31:49 -04:00
Karthik Rajasekaran a20259db73 Including buildtools as a source and update perf versions
Updating xunit.netcore.extensions to Microsoft.xunit.netcore.extensions


Commit migrated from https://github.com/dotnet/corefx/commit/099bc04f8a21d2c2d941ae359afbcde126c4d05a
2016-06-15 11:23:37 -07:00
Karthik Rajasekaran d73f6518c3 Update CoreFX tests to compile against a minimum of netstandard1.3 and add supports clauses for tests
CoreFX tests will now compile against netstandard1.3 as references and will now deploy for the platforms listed in their respective supports clause, provided the appropriate TestTFM is passed in.  The supports are fully listed inside runtime.json in the new TestSuite metapackage in buildtools. The tests will default to netcoreapp1.0 as their TestTFM.

CoreFx test projects now utilise a test csproj to pkgproj reference which determine the appropriate compile time and runtime assets needed.

Dependent on https://github.com/dotnet/buildtools/pull/770


Commit migrated from https://github.com/dotnet/corefx/commit/b4841454de7ddcd75e92e2bb24ebb238a82df43f
2016-06-15 11:23:11 -07:00
Stephen Toub 9f8a0e9b29 Ensure correct exception is thrown in several situations
- Our closing the socket may trigger our own pending receive to return successfully with 0 bytes read, as if the other end had closed the connection.  We need to treat this as an ObjectDisposedException to match the Windows behavior.
- If the Socket ends with an operation canceled code, we should throw an OperationCanceledException to match the Windows behavior.
- When using wss (https), we use an SslStream, and if the underlying stream is disposed of, SslStream may throw an InvalidOperationException due to the connection no longer being authenticated.  That needs to be translated into the appropriate exception type to match Windows behavior.


Commit migrated from https://github.com/dotnet/corefx/commit/2e59fabb707f8f3437d69bfdf683d1ae1b38fcd5
2016-06-15 10:48:11 -04:00
Stephen Toub 39d976dd10 Address PR feedback
Commit migrated from https://github.com/dotnet/corefx/commit/5c5c349ddbe40d62731c8772b24d69db96a71c88
2016-06-15 10:48:11 -04:00
Stephen Toub 761ff159aa Fix stream disposal causing test failures
Two issues, one preexisting this change and one introduced by it.
- Preexisting: TcpClient on Unix simulates socket.Connect(string host, int port) by creating a new Socket for each possible address we're attempting to connect to.  As a result, if the TcpClient is Dispose'd before the connection is successful, we won't yet have stored the actual Socket into the TcpClient and we won't end up Dispose'ing the Socket.  Then subsequent attempts to send/receive on that socket will continue, as they will be operating on a valid Socket.
- New: Previously the Socket would end up being Dispose'd of when we Dispose'd of the TcpClient we were holding on to.  now that Dispose happens via the NetworkStream.  But we weren't passing ownsSocket: true to the NetworkStream, so when it was Dispose'd, it wasn't Dispose'ing of the Socket, resulting in similar hangs when trying to send/receive in abort scenarios.


Commit migrated from https://github.com/dotnet/corefx/commit/270a831355b9a58913652320f8f6e0a610275d8f
2016-06-15 10:48:11 -04:00
Stephen Toub c71d26e106 Delete unused resources in Strings.resx
Commit migrated from https://github.com/dotnet/corefx/commit/4e3f738215c3e3051dad1d849d67a493f1b35279
2016-06-15 10:48:11 -04:00
Stephen Toub 80c5b03e4a Use nameof in ClientWebSocket
Happened to notice these while doing perf work.


Commit migrated from https://github.com/dotnet/corefx/commit/7961871d88950d75d9eb414528a047025a582a40
2016-06-15 10:48:11 -04:00
Stephen Toub 49a9d1be36 Inline EnsureBufferContainsHeaderAsync into ReceiveAsyncPrivate
Avoids an extra async method (and its associated allocations) on the path where we typically end up yielding waiting for data to arrive.


Commit migrated from https://github.com/dotnet/corefx/commit/c241cc4ca59b8d4ebabc567e333f1a4d9f4767e3
2016-06-15 10:48:11 -04:00
Stephen Toub f500d7fa16 Remove base class from ManagedWebSocket
It's an internal type, so there's no need for the base class or the virtual methods.  Also, since WebSocket is public, we want to avoid folks being able to cast Task.AsyncState to WebSocket and call methods on this internal object directly, just as a precaution against strange misuse.


Commit migrated from https://github.com/dotnet/corefx/commit/0f21c072c80c3eee7ac199fd01b763a670a225e7
2016-06-15 10:48:11 -04:00
Stephen Toub 2b2fcf8184 Optimize SendFrameAsync to minimize allocations
The previous commit was beneficial in avoiding one large set of overhead, but it also has a flaw that, due to a current behavior in Sockets, sending to a socket inevitably completes asynchronously, which means SendFrameAsync almost always hits an await that yields.  Since this is a very important code path, until the Socket issue can be addressed, we can optimize the common case to minimize the costs involved.


Commit migrated from https://github.com/dotnet/corefx/commit/3e795b025f10cd7c3382b06cbabba82d2094d2f5
2016-06-15 10:48:11 -04:00
Stephen Toub 2da9c33adb Use custom network stream in managed WebSockets on Unix
We only need to support a single read and a single write at a time, which means we can create two SocketAsyncEventArgs instances and repeatedly reuse them for all read and write operations on the stream.  This avoids a significant amount of the overhead involved in reading/writing with the network.


Commit migrated from https://github.com/dotnet/corefx/commit/7a2acc72a6b4ede8a7fa82e83b2a58e00e7e2b82
2016-06-15 10:48:11 -04:00
Stephen Toub 87c2b75a22 Move classes to their own files
No logic was changed.  Simply separated out each class into its own file.


Commit migrated from https://github.com/dotnet/corefx/commit/f1caf0ab01184951093e5ee4d701ea1d4159358d
2016-06-15 09:33:28 -04:00
Stephen Toub 839522f61f Reduce running time of WebSocket.Client tests
They currently take around ~40s on my laptop.  We can easily reduce this significantly by splitting the single test class into multiple test classes, allowing the default xunit parallelism to run them with more concurrency.  On my quad-core, such that xunit by default allows four tests to run concurrently, the tests now take ~10s.  This commit moves some of the shared logic into a base class, and then essentially replaces the regions with classes.  No test logic was changed at all.


Commit migrated from https://github.com/dotnet/corefx/commit/2a0819b66da873ee41c1ba30d93c3332bd39271b
2016-06-15 09:22:32 -04:00
Stephen Toub 0356525238 Updating CoreFx dependencies to rc4-24215-01
Commit migrated from https://github.com/dotnet/corefx/commit/8539c5c0e3fc42084ac06d7e4b6734df7fcf2932
2016-06-14 22:31:09 -04:00
dotnet-bot 73b89266d0 Updating CoreFx dependencies to rc4-24214-04
Commit migrated from https://github.com/dotnet/corefx/commit/c7fb2cef475f365a384d53b26d4c5612c91fff62
2016-06-14 19:12:33 +00:00
dotnet-bot 73e2af0256 Updating CoreFx dependencies to rc4-24214-03
Commit migrated from https://github.com/dotnet/corefx/commit/22efb2a5f992c25a9f215a13968d14c6903aa1d4
2016-06-14 13:14:07 +00:00
Stephen Toub 383e5f2e4a Update CoreFX and External Dependencies to 24214-02 and 24214-00
Commit migrated from https://github.com/dotnet/corefx/commit/d5dcad160fbe8b7a8cb4e37cda58b9beac5da47d
2016-06-14 07:14:56 -04:00
Stephen Toub 5ff126bfbb Merge pull request dotnet/corefx#9390 from dotnet-bot/UpdateDependencies20160613071843
Updating CoreFx dependencies to rc4-24213-04

Commit migrated from https://github.com/dotnet/corefx/commit/d7ebf210be076072f846f754967402947cc13668
2016-06-13 16:07:09 -04:00
Stephen Toub 8a36abeaf5 Merge pull request dotnet/corefx#9371 from stephentoub/websockets_perf
Remove some allocations from unix WebSocket client

Commit migrated from https://github.com/dotnet/corefx/commit/7b138290a2a02d5c1509fcc51f56929780c00c5d
2016-06-13 16:06:58 -04:00
dotnet-bot fdc79eb15e Updating CoreFx dependencies to rc4-24213-04
Commit migrated from https://github.com/dotnet/corefx/commit/50ef40f12ed40a7c497169826297ac61a121aa26
2016-06-13 19:18:43 +00:00
Stephen Toub 919cd9443b Address PR feedback
Commit migrated from https://github.com/dotnet/corefx/commit/ae1fef34fbfd2ab7a97172958bcd08b809c874e1
2016-06-13 13:53:20 -04:00
dotnet-bot f66c7664ff Updating CoreFx dependencies to rc4-24213-03
Commit migrated from https://github.com/dotnet/corefx/commit/210cf6dd24dac2e501d64079e922c9d9313ab56b
2016-06-13 13:11:54 +00:00
Stephen Toub 1d68eee786 Updating CoreFx dependencies to rc4-24213-02
Commit migrated from https://github.com/dotnet/corefx/commit/05b479256dfa89188c5cd66579114eb21794a6b2
2016-06-13 06:15:41 -04:00
dotnet-bot 246d7a0437 Updating CoreFx dependencies to rc4-24212-04
Commit migrated from https://github.com/dotnet/corefx/commit/a393af011454c8cdfe7c2e7ea2c1c295f8a4d61d
2016-06-12 19:09:29 +00:00
Stephen Toub e04f66a95b Updating CoreFx dependencies to rc4-24212-03
Commit migrated from https://github.com/dotnet/corefx/commit/b2ae3de5c802c7c62a85f342e9510b7e3aeb910a
2016-06-12 10:56:11 -04:00
Stephen Toub 8f9af76497 Remove WithAbortAsync
It's a hold-over from before I was aware that canceling an individual operation should actually abort the whole websocket.  Now that that's the case, it's much cheaper to just register with the token as part of the async operations, rather than wrapping each in another task that itself does such registration.


Commit migrated from https://github.com/dotnet/corefx/commit/35531db1ddea1137bbd026dcb82cb67910241503
2016-06-11 18:54:32 -04:00
Stephen Toub 76458b4e21 Remove an unnecessary CancellationToken registration
We don't need to pass the CancellationToken to the continuation in WithAbortAsync; doing so doesn't actually add value in this case, and it results not only in a registration in the CancellationToken, but also in expanding the continuation task's contingent properties.


Commit migrated from https://github.com/dotnet/corefx/commit/3a5a02e8f153055a4705d619b2045883ef325b28
2016-06-11 17:49:09 -04:00
Stephen Toub 6b53ff62a3 Change how message headers are read
Instead of ReadMessageHeaderAsync, use a pair of EnsureBufferContainsHeaderAsync and ParseMessageHeaderFromReceiveBuffer, which avoids several allocations in the case of the header already being in the buffer and using smaller allocations if one isn't.


Commit migrated from https://github.com/dotnet/corefx/commit/c96eee1452e0293ceb70bb2dc0c55007c36ef621
2016-06-11 17:48:03 -04:00
Stephen Toub 905901d32c Improve WebSocket receive perf with receive buffer
Commit migrated from https://github.com/dotnet/corefx/commit/f10e413062030b778921d05001df327bf6ab5d53
2016-06-11 08:40:38 -04:00
Stephen Toub f1af179448 Initial System.Net.WebSockets.Client implementation on Unix
This PR provides an initial implementation of the client WebSockets library for Unix.  It's actually not Unix-specific, and rather is a managed implementation on top of System.Net.Sockets and System.Net.Security.

I opted to start with a managed implementation as there does not appear to be a universally-adopted native implementation we can utilize.  I looked to see if we could just adopt the Mono implementation, but it's based on HttpWebRequest, which in corefx is built on top of HttpClient, which isn't particularly amenable to being used for websockets (and libcurl does not have websockets support).

This is passing all of the unit/functional tests, including a few more I added.  It's also passing all of the AutobahnWS tests (two with non-strict results), except for the compression ones, as that's not implemented.

I've spent close to zero time looking at performance; I'm sure there are opportunities to make meaningful improvements, but for now I've opted for simplicity and functionality.  There are also two features I didn't implement: proxies and credentials... but it doesn't look like either the WinHttp or WinRT implementations pay attention to those either.


Commit migrated from https://github.com/dotnet/corefx/commit/b726c18227cf1c3cee21df86d762d557fd81a5e1
2016-06-11 05:51:14 -04:00
dotnet-bot eb296c0c86 Updating CoreFx dependencies to rc4-24211-02
Commit migrated from https://github.com/dotnet/corefx/commit/9ee0ac2dee8360086f545ae9b7ebf183312146ea
2016-06-11 07:19:19 +00:00
Stephen Toub dccbf3a89d Updating CoreFx dependencies to rc4-24210-04
Commit migrated from https://github.com/dotnet/corefx/commit/3473c3dce764e2aa30497e0476acdac8298822ed
2016-06-10 12:48:41 -04:00
dotnet-bot 1a3d275bc9 Updating CoreFx dependencies to rc4-24210-03
Commit migrated from https://github.com/dotnet/corefx/commit/2358285c88c2055040b979b87475cdfbc14ada1b
2016-06-10 08:08:26 +00:00
dotnet-bot ed36474dbf Updating CoreFx dependencies to rc4-24209-03
Commit migrated from https://github.com/dotnet/corefx/commit/4786e13a70b20350f77d047624384090341acfa1
2016-06-09 13:19:12 +00:00
dotnet-bot 2e6b9dc990 Updating CoreFx dependencies to rc4-24208-04
Commit migrated from https://github.com/dotnet/corefx/commit/02515a1ace7d60e2b8b63c4b80427b0a1275503c
2016-06-08 18:43:01 +00:00