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

Closed
KKhurin opened this Issue Feb 15, 2013 · 5 comments

Projects

None yet

5 participants

@KKhurin
KKhurin commented Feb 15, 2013

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

@davidfowl davidfowl was assigned Feb 15, 2013
@davidfowl
Member

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
Member

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 added a commit that referenced this issue Mar 13, 2013
@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 added a commit that referenced this issue Mar 13, 2013
@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 added a commit that referenced this issue Mar 13, 2013
@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 added a commit that referenced this issue Mar 13, 2013
@NTaylorMullen NTaylorMullen Split the EventSourceStreamReader into two classes, an AsyncStreamRea…
…der and the original EventSourceStreamReader

#1536
bb8ec78
@NTaylorMullen NTaylorMullen added a commit that referenced this issue Mar 13, 2013
@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 added a commit that referenced this issue Mar 19, 2013
@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 added a commit that referenced this issue Mar 19, 2013
@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 added a commit that referenced this issue Mar 19, 2013
@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 added a commit that referenced this issue Mar 19, 2013
@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 added a commit that referenced this issue Mar 19, 2013
@NTaylorMullen NTaylorMullen Split the EventSourceStreamReader into two classes, an AsyncStreamRea…
…der and the original EventSourceStreamReader

#1536
4c3a1eb
@NTaylorMullen NTaylorMullen added a commit that referenced this issue Mar 19, 2013
@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 added a commit that referenced this issue Mar 19, 2013
@NTaylorMullen NTaylorMullen Addressed FXCop issues
- Also caught a few issues that were pre-existing from rebase

#1536
570f6e0
@Xiaohongt Xiaohongt was assigned Mar 20, 2013
@NTaylorMullen NTaylorMullen added a commit that referenced this issue Mar 20, 2013
@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 added a commit that referenced this issue Mar 20, 2013
@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 added a commit that referenced this issue Mar 20, 2013
@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 added a commit that referenced this issue Mar 20, 2013
@NTaylorMullen NTaylorMullen Split the EventSourceStreamReader into two classes, an AsyncStreamRea…
…der and the original EventSourceStreamReader

#1536
be6dd2f
@NTaylorMullen NTaylorMullen added a commit that referenced this issue Mar 20, 2013
@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 added a commit that referenced this issue Mar 20, 2013
@NTaylorMullen NTaylorMullen Addressed FXCop issues
- Also caught a few issues that were pre-existing from rebase

#1536
2c0c7a7
@jcondex jcondex was assigned Mar 25, 2013
@Xiaohongt
Contributor

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

@davidfowl
Member

Closing

@davidfowl davidfowl closed this Mar 25, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment