Comments (5)
Hi,
The anonymous function should not be an issue, my guess is probably the Nuget is not throwing the error visually. If you check the "Output" window in "Debug" option maybe you should see the error too with Nuget.
Related to the issue, are you disposing the webworker when the exception raised?
I'm trying the next code, but I can't get the HttpListenerException.
using System;
using System.ComponentModel;
using Unosquare.Labs.EmbedIO;
using Unosquare.Labs.EmbedIO.Modules;
namespace ConsoleApplication1
{
internal class Program
{
private static void Main(string[] args)
{
var web = new WebWorker((Unosquare.Labs.EmbedIO.WebServer server) =>
{
server.Module<Unosquare.Labs.EmbedIO.Modules.WebApiModule>().RegisterController<StorageController>();
server.Module<Unosquare.Labs.EmbedIO.Modules.WebApiModule>().RegisterController<LogController>();
});
web.Start();
Console.ReadLine();
}
}
internal class StorageController : WebApiController
{
}
internal class LogController : WebApiController
{
}
internal class WebWorker
{
private string Url = "http://localhost:9696/";
private Action<WebServer> doStuff;
private readonly BackgroundWorker serverWorker;
public WebWorker(Action<WebServer> doStuff = null)
{
this.doStuff = doStuff;
serverWorker = new BackgroundWorker()
{
WorkerReportsProgress = true,
WorkerSupportsCancellation = true,
};
serverWorker.DoWork += DoWorkHandler;
}
public void Start()
{
serverWorker.RunWorkerAsync(@"C:\unosquare\unosquare.github.io");
}
private void DoWorkHandler(object sender, DoWorkEventArgs e)
{
using (var server = new WebServer(Url))
{
server.RegisterModule(new StaticFilesModule(e.Argument.ToString()));
server.RegisterModule(new WebApiModule());
if (doStuff != null)
{
doStuff(server);
}
server.RunAsync();
while (serverWorker.CancellationPending == false)
{
System.Threading.Thread.Sleep(100);
}
}
}
}
}
from embedio.
I was actually expecting that it was silently happening. And no I'm not explicitly disposing the worker when the exception is raised, if you mean what I think then it's not necessary considering what I read on stackoverflow about this.
from embedio.
Hey @srad, I'm still trying to reproduce the issue. I added the next code at Webserver.cs line 306
catch (HttpListenerException listenerEx)
{
var errorMessage = listenerEx.ExceptionMessage("Failing HttpListenerException: " + module.Name);
Log.Error(errorMessage, listenerEx);
return;
}
And I created a simple webrequestor to be requesting the index page constantly but the debugger is never hitting the ListenerException.
Can you share me a little bit more your code?
from embedio.
Hi, I hadn't had the time to look thoroughly into this, for now I just ignored the exception.
What I can say is that I served an Html page which contained an <audio>
element to a mp3 file, when the exception was raised.
from embedio.
Closing as no further feedback was received and the issue could not be reproduced.
from embedio.
Related Issues (20)
- How to send statuscode 202 HOT 1
- EmbedIO 3.5.0 NuGet package references wrong/old version of Unosquare.Swan.Lite HOT 22
- System.ObjectDisposedException when processing multiple requests at once HOT 2
- WithZipFile should open a read only handle(or have the option to) HOT 2
- FileModule or StaticFolderModule get stuck returning medium files HOT 4
- Add XML as response type
- EmbedIO Dual-Stack Localhost Listener Causes Empty Replies HOT 1
- How can I custom the Server header HOT 2
- Disable request logging only
- Cookies issue
- EmbedIO.Samples console app does not work when PublishAot is set to true HOT 2
- Web Server does not work in Xamarin.iOS (IOS-17) HOT 3
- How to report progess via api - event-stream
- HttpContext.OnClose not firing HOT 1
- Getting rid of double quotes around strings in a Web API response (turning off JSON serialization) HOT 1
- Issue Serving Static Folder Xamarin ( 3.5.2) Forms on Android
- Request.Url mixing up http and https
- server stop responding after some time HOT 4
- The return array is empty. HOT 1
- Crash the webserver and restart the main application
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from embedio.