Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Get rid of all synchronous reads/writes on the client #1536

Closed
KKhurin opened this Issue · 5 comments

5 participants

@KKhurin
Collaborator

Under stress it will cause thread starvation and introduce additional timeouts.

@davidfowl davidfowl was assigned
@davidfowl
Owner

Silverlight issues.

Message : Specified method is not supported.
StackTrace:   at System.Net.Browser.BHWRAsyncResult.get_AsyncWaitHandle()
Failed to read response: System.NotSupportedException: Read is not supported on the main thread when buffering is disabled.
at MS.Internal.InternalNetworkStream.Read(Byte[] buffer, Int32 offset, Int32 count)
at System.IO.StreamReader.ReadBuffer()
at System.IO.StreamReader.ReadToEnd()
at Microsoft.AspNet.SignalR.Client.Http.HttpHelper.ReadAsString(HttpWebResponse response)
``
@davidfowl
Owner

As part of this change. We'll be changing the client side IResponse API to be a single member:

public interface IResponse : IDisposable
{
    public Stream GetStream();
}

Move ReadAsString to an extension method and make it return Task<string> instead of a string and fix all of the call sites for this method.

@NTaylorMullen NTaylorMullen referenced this issue from a commit
@NTaylorMullen NTaylorMullen Modified the IResponse object to only contain a GetStream member and …
…moved the ReadAsString method to an extension

- Also Changed the ReadAsString method to return a task of string.
#1536
0a58ab0
@NTaylorMullen NTaylorMullen referenced this issue from a commit
@NTaylorMullen NTaylorMullen Modified existing classes to utilize the new IResponse object.
- Also instead of Close we now close out the response on dispose, hence the IDisposable.
#1536
dc1e92e
@NTaylorMullen NTaylorMullen referenced this issue from a commit
@NTaylorMullen NTaylorMullen Modified the TransportFacts SendCatchesOnReceivedExceptions to mock t…
…he GetStream member of IResponse

- Now that ReadAsString is an extension method you aren't easily able to mock it therefore we have to create a stream, write a value to it and then mock the GetStream member
#1536
feb0eca
@NTaylorMullen NTaylorMullen referenced this issue from a commit
@NTaylorMullen NTaylorMullen Split the EventSourceStreamReader into two classes, an AsyncStreamRea…
…der and the original EventSourceStreamReader

#1536
bb8ec78
@NTaylorMullen NTaylorMullen referenced this issue from a commit
@NTaylorMullen NTaylorMullen Modified the ThreadSafeInvoker to be a class instead of a struct
- Within the LongPollingTransport it was passing the ThreadSafeInvoker
around and as it was passed it was consistently copied.  Therefore
changing it to a class results in it being passed by reference.

#1536
06146da
@NTaylorMullen NTaylorMullen referenced this issue from a commit
@NTaylorMullen NTaylorMullen Modified the ThreadSafeInvoker to be a class instead of a struct
- Within the LongPollingTransport it was passing the ThreadSafeInvoker
around and as it was passed it was consistently copied.  Therefore
changing it to a class results in it being passed by reference.

#1536
d672630
@NTaylorMullen NTaylorMullen referenced this issue from a commit
@NTaylorMullen NTaylorMullen Modified the IResponse object to only contain a GetStream member and …
…moved the ReadAsString method to an extension

- Also Changed the ReadAsString method to return a task of string.
#1536
200f766
@NTaylorMullen NTaylorMullen referenced this issue from a commit
@NTaylorMullen NTaylorMullen Modified existing classes to utilize the new IResponse object.
- Also instead of Close we now close out the response on dispose, hence the IDisposable.
#1536
0f9688a
@NTaylorMullen NTaylorMullen referenced this issue from a commit
@NTaylorMullen NTaylorMullen Modified the TransportFacts SendCatchesOnReceivedExceptions to mock t…
…he GetStream member of IResponse

- Now that ReadAsString is an extension method you aren't easily able to mock it therefore we have to create a stream, write a value to it and then mock the GetStream member
#1536
4cfdb57
@NTaylorMullen NTaylorMullen referenced this issue from a commit
@NTaylorMullen NTaylorMullen Split the EventSourceStreamReader into two classes, an AsyncStreamRea…
…der and the original EventSourceStreamReader

#1536
4c3a1eb
@NTaylorMullen NTaylorMullen referenced this issue from a commit
@NTaylorMullen NTaylorMullen Modified the ThreadSafeInvoker to be a class instead of a struct
- Within the LongPollingTransport it was passing the ThreadSafeInvoker
around and as it was passed it was consistently copied.  Therefore
changing it to a class results in it being passed by reference.

#1536
d8d9c1b
@NTaylorMullen NTaylorMullen referenced this issue from a commit
@NTaylorMullen NTaylorMullen Addressed FXCop issues
- Also caught a few issues that were pre-existing from rebase

#1536
570f6e0
@Xiaohongt Xiaohongt was assigned
@NTaylorMullen NTaylorMullen referenced this issue from a commit
@NTaylorMullen NTaylorMullen Modified the IResponse object to only contain a GetStream member and …
…moved the ReadAsString method to an extension

- Also Changed the ReadAsString method to return a task of string.
#1536
94b30ba
@NTaylorMullen NTaylorMullen referenced this issue from a commit
@NTaylorMullen NTaylorMullen Modified existing classes to utilize the new IResponse object.
- Also instead of Close we now close out the response on dispose, hence the IDisposable.
#1536
cbde9db
@NTaylorMullen NTaylorMullen referenced this issue from a commit
@NTaylorMullen NTaylorMullen Modified the TransportFacts SendCatchesOnReceivedExceptions to mock t…
…he GetStream member of IResponse

- Now that ReadAsString is an extension method you aren't easily able to mock it therefore we have to create a stream, write a value to it and then mock the GetStream member
#1536
04c0f12
@NTaylorMullen NTaylorMullen referenced this issue from a commit
@NTaylorMullen NTaylorMullen Split the EventSourceStreamReader into two classes, an AsyncStreamRea…
…der and the original EventSourceStreamReader

#1536
be6dd2f
@NTaylorMullen NTaylorMullen referenced this issue from a commit
@NTaylorMullen NTaylorMullen Modified the ThreadSafeInvoker to be a class instead of a struct
- Within the LongPollingTransport it was passing the ThreadSafeInvoker
around and as it was passed it was consistently copied.  Therefore
changing it to a class results in it being passed by reference.

#1536
0a3fad4
@NTaylorMullen NTaylorMullen referenced this issue from a commit
@NTaylorMullen NTaylorMullen Addressed FXCop issues
- Also caught a few issues that were pre-existing from rebase

#1536
2c0c7a7
@jcondex jcondex was assigned
@Xiaohongt
Collaborator

verified for functional tests. After stress tests for this pass, then this can be closed, assign it to @jcondex

@davidfowl
Owner

Closing

@davidfowl davidfowl closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.