GithubHelp home page GithubHelp logo

Comments (4)

rdeago avatar rdeago commented on June 15, 2024

Hello @lucapivato, thanks for using EmbedIO!

I agree with you that something is wrong here, but I'm not sure it's FileModule's fault.

As your screenshot shows, the request for favicon.ico went through WebServerBase<TOptions>.DoHandleContextAsync in about one millisecond (15:19:01.404 > 15:19:01.405). For reference, here is the code that writes the first and last log lines related to the request, at line 236 at 286 respectively.

Still, when the last of the three involved lines is logged, the HTTP context has an age (time elapsed since creation) of more than 18 seconds. This seems to indicate that most of that time was spent between the creation of the HTTP context and its handling, therefore in the not-yet-fully-explored (by me, at least) territory of HttpListener and related classes.

If you can (i.e. if your server runs on Windows) try replacing the first line of your code with the following and see if you observe the same behavior:

var server = new WebServer(o => o
    .WithMode(HttpListenerMode.Microsoft)
    .WithUrlPrefix("http://localhost:5000/"));

Also, the log of the first overly-delayed request and the two or three previous requests might help.

from embedio.

lucapivato avatar lucapivato commented on June 15, 2024

Yes, favicon is a side effect. After returning a js file of about 1Mb to 6Mb it starts hanging for other files too. I tried returning it directly WithAction() and using the OpenResponseStream() but it's more or less the same, the browser keeps spinning as if the connection was kept open. Tried closing the stream, flushing, etc. Tried writing directly to the OutputStream but same reasult.

.WithMode(HttpListenerMode.Microsoft) didn't change the behavior.

In case you want to test it, I have attached one of the js files. I don't know if the issue is the UTF-8 encoding (at one point we got an exception related to the 1252 encoding on MAUI but cannot reproduce), we tried with a 6Mb xml file and it worked fine. Tried the managed HttpListener directly in Windows and iOS with the same files and it worked fine.

Wisej.Platform.qx.zip

Thank you.

from embedio.

rdeago avatar rdeago commented on June 15, 2024

Thanks for the file, but this issue does not seem to be about the specific file being requested.

The delay happens before EmbedIO even has a chance of dispatching the request; that's why using an ActionModule makes no difference. It looks like the request gets stuck in EmbedIO's request queue, as if the thread pool has no thread left to handle it, which is unusual to say the least.

Can you get a screenshot showing the sequence of requests made to the server? I think Chrome's DevTools may help with this.

A complete log from the server may also be of help. You can activate logging on file by adding the following line before server initialization:

using Swan.Logging; // <-- You need this too

Logger.RegisterLogger(new FileLogger("PATH_TO_LOG_FILE", false));

from embedio.

cho-trackman avatar cho-trackman commented on June 15, 2024

I'm stuck debugging this issue. I did come to the same conclusion that the thread pool get exhausted somehow, because all "life signs" vanishes after hitting the issue.
It seems to affect all module types.
For now my "solution" is to keep the JSON responses under 1MB (which is sometimes needed).

from embedio.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.