Pointy
Posts: 10
Joined: Mon May 30, 2016 7:07 pm

Re: Simple embedded HTTP server library

Wed Jun 15, 2016 8:26 am

I had another error last night, which I think happened after my PC dropped off the network.(It was connected to the Pi3 at the time)

Code: Select all

An existing connection was forcibly closed by the remote host.

   at System.IO.StreamOperationAsyncResult.ThrowWithIOExceptionDispatchInfo(Exception e)
   at System.IO.StreamOperationAsyncResult.ProcessCompletedOperation()
   at System.IO.WinRtToNetFxStreamAdapter.EndRead(IAsyncResult asyncResult)
   at System.IO.WinRtToNetFxStreamAdapter.Read(Byte[] buffer, Int32 offset, Int32 count)
   at System.IO.BufferedStream.Read(Byte[] array, Int32 offset, Int32 count)
   at Feri.MS.Http.HttpRequest.Init(StreamSocket data)
Exception thrown: 'System.NullReferenceException' in HttpServer.dll
The error was thrown at line 337 in HttpServer.cs.(_hrequest.HttpConnection was null)...

Code: Select all

_log.WriteLine("Error:" + DateTime.Now.ToString("R") + ": " + _hrequest.HttpConnection.RemoteHost + ": " + _hrequest.HttpConnection.LocalHost + ": " + _hrequest.RequestString().TrimEnd());
Regards,

Les

miha1
Posts: 22
Joined: Mon Feb 22, 2016 12:56 pm

Re: Simple embedded HTTP server library

Sat Jun 18, 2016 10:23 am

Hello,

Thank you for the error report.

Crash was caused by framework closing connection during input stream read operation, caused by client disconnect. (both errors you reported are related)

I fixed the issue and uploaded version 2.0.4 to the github.

Isue here is, integrity of data we recived up to this point is compromised and attempting to parse it would most likely fail. For this reason we discard the content of the input buffer and report init failed to HttpServer.
This will cause the HttpServer to write log entry and attempt to send error 500 to the client. Since client is disconnected, nothing will be sent.

With kind regards,

------
Miha

Pointy
Posts: 10
Joined: Mon May 30, 2016 7:07 pm

Re: Simple embedded HTTP server library

Mon Jun 20, 2016 9:23 pm

Thanks again for the update, and I am sorry to keep doing this to you but I had another crash today. (My network is playing up, and I think it's time for a new router!)

Crash happened after the network dropped...

Code: Select all

Exception thrown: 'System.Runtime.InteropServices.COMException' in HttpServer.dll
WinRT information: An existing connection was forcibly closed by the remote host.

Additional information: An existing connection was forcibly closed by the remote host.

An existing connection was forcibly closed by the remote host.

httpserver.cs: line 277

listener.ConnectionReceived += (sender, args) => ProcessRequestAsync(args.Socket);
Regards,

Les

miha1
Posts: 22
Joined: Mon Feb 22, 2016 12:56 pm

Re: Simple embedded HTTP server library

Fri Jun 24, 2016 12:53 pm

Hello,

I am happy to get bug reports, it leads to more reliable code, so don't worry about it. :)

As far as i can tell, the error you got is framework error ConnectionResetByPeer, caused by dropped connection.
I changed the code, so it should hopefully resolve the issue. Connection drops are a bit random and hard to test; my test Win IoT have been connected to internet and running without error for over a month now.

I also added a bit more verbose error messages if exception is thrown.

With kind regards,

----
Miha

Pointy
Posts: 10
Joined: Mon May 30, 2016 7:07 pm

Re: Simple embedded HTTP server library

Fri Jun 24, 2016 6:10 pm

miha1 wrote:I am happy to get bug reports, it leads to more reliable code, so don't worry about it. :)
Well you will be pleased to know I have installed a new router, so Maybe I won't crash your software so much. ;)
miha1 wrote:Connection drops are a bit random and hard to test; my test Win IoT have been connected to internet and running without error for over a month now.
I got another crash yesterday, when replacing the router, So I am guessing rebooting your modem/router with an open connection would be a good test. ;)

On another note, any plans to add file/folder support for the web files? Embedding them is a pain and limits the customisation of the end product.

Regards,

Les

miha1
Posts: 22
Joined: Mon Feb 22, 2016 12:56 pm

Re: Simple embedded HTTP server library

Sat Jun 25, 2016 3:35 pm

Pointy wrote: Well you will be pleased to know I have installed a new router, so Maybe I won't crash your software so much. ;)
:)
Pointy wrote: I got another crash yesterday, when replacing the router, So I am guessing rebooting your modem/router with an open connection would be a good test. ;)
With 0.2.0.6? it should not have crashed, can you post the error message?
Pointy wrote: On another note, any plans to add file/folder support for the web files? Embedding them is a pain and limits the customisation of the end product.
I agree, and actually, there are plans! I was working on extended data source support in development branch, but it's a bit delayed due to virtual site (ability to host multiple sites on single server) support. Api support is there, but provider was not implemented yet. It is still on to-do list and will be implemented soon. Currenty, development branch does not compile/work, due to virtual site work, though.

With kind regards,

----
Miha

Pointy
Posts: 10
Joined: Mon May 30, 2016 7:07 pm

Re: Simple embedded HTTP server library

Sat Jun 25, 2016 3:49 pm

miha1 wrote:With 0.2.0.6? it should not have crashed, can you post the error message?
It was before I upgraded to 0.2.0.6 and was the same error as before, I will let you know if I get any more crashes with the latest version.
miha1 wrote:I agree, and actually, there are plans! I was working on extended data source support in development branch, but it's a bit delayed due to virtual site (ability to host multiple sites on single server) support. Api support is there, but provider was not implemented yet. It is still on to-do list and will be implemented soon. Currenty, development branch does not compile/work, due to virtual site work, though.
Glad to know it's on the list, I will keep an eye out for it, in future versions.

Regards,

Les

slafoy
Posts: 4
Joined: Mon Nov 21, 2016 6:47 pm

Re: Simple embedded HTTP server library

Tue Jan 03, 2017 6:57 pm

I have been using the for a couple weeks now. Nice job on it!

I have been controlling a pi from a pi with a screen. I have had to use the ip address of the slave pi to be able to control it. That was fine until the ip address changes then I have to change it in the app controlling it. Is there a way to find the server on a local network by name?

Alejandro3071
Posts: 1
Joined: Thu Aug 24, 2017 9:34 pm

Re: Simple embedded HTTP server library

Thu Aug 24, 2017 10:07 pm

Hi!! First of all thank the development, I'm just starting to use it. I found something curious and it is mentioned that the basic function would suffice to call

Code: Select all

 server = new HttpServer();
            server.Start();
But when you run you always send the error of: System.NullReferenceException en la siguiente sección de HttpServer.cs
Error1.PNG
Error1
Error1.PNG (29.77 KiB) Viewed 1765 times
The error occurs because of _ RootManager that at no time is set to a value.
Somewhere is missing the call to:

Code: Select all

public IHttpRootManager HttpRootManager
        {
            get
            {
                if (_rootManager == null)
                {
                    _rootManager = new DefaultHttpRootManager();
                    _rootManager.AddSource(new EmbeddedContent(this.GetType()));
                    _rootManager.Start(this);
                }
                return _rootManager;
            }
            set
            {
                if (_rootManager != null)
                {
                    _rootManager.Stop();
                }
                _rootManager = value;
                _rootManager.Start(this);
            }
        }
So that it works in a basic way and with the page by default

Code: Select all

server = new HttpServer();
            server.Start();
            IHttpRootManager ser = server.HttpRootManager;
A little detail! I don't know where it would be modified to be grabbed by default. I will continue working with the bookstore again thank you very much for the development I hope not to leave it. Best regards!!

colonelsoftware
Posts: 1
Joined: Mon Dec 03, 2018 11:01 am

Re: Simple embedded HTTP server library

Mon Dec 03, 2018 11:10 am

Hello,

Thanks for the post.
I am new to Windows IOT and i am unable to understand the steps that how to debug the project.
Can you please describe the steps for integrate the same.

Thanks & regards
ColonelSoftware

Return to “Windows 10 for IoT”