Skip to content

Getting "Unable to read data from the transport connection" exceptions on every request #14

@daveaglick

Description

@daveaglick

I'm excited to get uHttpSharp working - the simplicity of design is exactly what I'm looking for. However, I've got a simple example up and running and keep getting a System.IO.IOException with the message Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. after every request (it's showing up in the trace output).

Here's my code:

HttpServer httpServer = new HttpServer(new HttpRequestProvider());
httpServer.Use(new TcpListenerAdapter(new TcpListener(IPAddress.Loopback, _previewPort)));
FileHandler.HttpRootDirectory = _engine.OutputFolder;
httpServer.Use(new FileHandler());
httpServer.Use(new ErrorHandler());
httpServer.Start();

And here's the trace output:

2015-06-03 05:54:41 [INFO]  (uhttpsharp.HttpClientHandler) Got Client 127.0.0.1:58269
2015-06-03 05:54:41 [INFO]  (uhttpsharp.HttpClientHandler) 127.0.0.1:58269 : Got request /Index.html
2015-06-03 05:54:42 [INFO]  (uhttpsharp.HttpClientHandler) Got Client 127.0.0.1:58270
2015-06-03 05:54:43 [WARN]  (uhttpsharp.HttpClientHandler) Error while serving : 127.0.0.1:58269
System.IO.IOException
Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   at System.IO.BufferedStream.Read(Byte[] array, Int32 offset, Int32 count)
   at uhttpsharp.LimitedStream.Read(Byte[] buffer, Int32 offset, Int32 count) in c:\Users\shani\Documents\GitHub\uHttpSharp\uhttpsharp\LimitedStream.cs:line 129
   at uhttpsharp.NotFlushingStream.Read(Byte[] buffer, Int32 offset, Int32 count) in c:\Users\shani\Documents\GitHub\uHttpSharp\uhttpsharp\HttpClient.cs:line 209
   at System.IO.Stream.<BeginReadInternal>b__a(Object param0)
   at System.Threading.Tasks.Task`1.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.IO.Stream.EndRead(IAsyncResult asyncResult)
   at System.IO.Stream.<BeginEndReadAsync>b__e(Stream stream, IAsyncResult asyncResult)
   at System.Threading.Tasks.TaskFactory`1.FromAsyncTrimPromise`1.Complete(TInstance thisRef, Func`3 endMethod, IAsyncResult asyncResult, Boolean requiresSynchronization)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
   at uhttpsharp.RequestProviders.MyStreamReader.<ReadBuffer>d__0.MoveNext() in c:\Users\shani\Documents\GitHub\uHttpSharp\uhttpsharp\RequestProviders\IStreamReader.cs:line 64
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult()
   at uhttpsharp.RequestProviders.MyStreamReader.<ReadLine>d__3.MoveNext() in c:\Users\shani\Documents\GitHub\uHttpSharp\uhttpsharp\RequestProviders\IStreamReader.cs:line 77
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
   at uhttpsharp.RequestProviders.HttpRequestProvider.<Provide>d__4.MoveNext() in c:\Users\shani\Documents\GitHub\uHttpSharp\uhttpsharp\RequestProviders\HttpRequestProvider.cs:line 22
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
   at uhttpsharp.HttpClientHandler.<Process>d__1.MoveNext() in c:\Users\shani\Documents\GitHub\uHttpSharp\uhttpsharp\HttpClient.cs:line 74
2015-06-03 05:54:43 [INFO]  (uhttpsharp.HttpClientHandler) Lost Client 127.0.0.1:58269
2015-06-03 05:54:43 [WARN]  (uhttpsharp.HttpClientHandler) Error while serving : 127.0.0.1:58270
System.IO.IOException
Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   at System.IO.BufferedStream.Read(Byte[] array, Int32 offset, Int32 count)
   at uhttpsharp.LimitedStream.Read(Byte[] buffer, Int32 offset, Int32 count) in c:\Users\shani\Documents\GitHub\uHttpSharp\uhttpsharp\LimitedStream.cs:line 129
   at uhttpsharp.NotFlushingStream.Read(Byte[] buffer, Int32 offset, Int32 count) in c:\Users\shani\Documents\GitHub\uHttpSharp\uhttpsharp\HttpClient.cs:line 209
   at System.IO.Stream.<BeginReadInternal>b__a(Object param0)
   at System.Threading.Tasks.Task`1.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.IO.Stream.EndRead(IAsyncResult asyncResult)
   at System.IO.Stream.<BeginEndReadAsync>b__e(Stream stream, IAsyncResult asyncResult)
   at System.Threading.Tasks.TaskFactory`1.FromAsyncTrimPromise`1.Complete(TInstance thisRef, Func`3 endMethod, IAsyncResult asyncResult, Boolean requiresSynchronization)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
   at uhttpsharp.RequestProviders.MyStreamReader.<ReadBuffer>d__0.MoveNext() in c:\Users\shani\Documents\GitHub\uHttpSharp\uhttpsharp\RequestProviders\IStreamReader.cs:line 64
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult()
   at uhttpsharp.RequestProviders.MyStreamReader.<ReadLine>d__3.MoveNext() in c:\Users\shani\Documents\GitHub\uHttpSharp\uhttpsharp\RequestProviders\IStreamReader.cs:line 77
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
   at uhttpsharp.RequestProviders.HttpRequestProvider.<Provide>d__4.MoveNext() in c:\Users\shani\Documents\GitHub\uHttpSharp\uhttpsharp\RequestProviders\HttpRequestProvider.cs:line 22
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
   at uhttpsharp.HttpClientHandler.<Process>d__1.MoveNext() in c:\Users\shani\Documents\GitHub\uHttpSharp\uhttpsharp\HttpClient.cs:line 74
2015-06-03 05:54:43 [INFO]  (uhttpsharp.HttpClientHandler) Lost Client 127.0.0.1:58270

Any ideas what I'm doing wrong?

Also, on an unrelated note I noticed this is forked from int6/uhttpsharp, but this fork seems to have more activity and is the one referenced from NuGet. What is the relationship between the two repositories?

Thanks!

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions