Embedio: The HTTP listener does not start.

Created on 20 Jan 2018  路  7Comments  路  Source: unosquare/embedio

Hello,
When I do this :

_server = new WebServer(8844, RoutingStrategy.Regex);>

this happens:

22:43:50.114 INF >> [WebServer] Web server prefix 'http://*:8844/' added.
22:43:50.121 INF >> [WebServer] Finished Loading Web Server.

for some reason the HTTP listener is not started.
But when I do something like this :

_server = new WebServer("http://localhost:8844/", RoutingStrategy.Regex);

The HTTP listener starts.

22:48:03.311 INF >> [WebServer] Web server prefix 'http://localhost:8844/' added.
22:48:03.318 INF >> [WebServer] Finished Loading Web Server.
22:48:03.344 INF >> [WebServer] Started HTTP Listener

I tried to find something in the code that could help me but I failed.
Thank you for your time.

bug

Most helpful comment

@jpalcala please add a better error handler when the HttpListener is unable to open the port because the process is not running in admin mode.

All 7 comments

Okay problem solved, I just had to open the app in Administrator mode.
Also it would be nice if you would dump the listener exceptions to the log.

Have a nice day.

Yeah, let me add a ticket about this.

@jpalcala please add a better error handler when the HttpListener is unable to open the port because the process is not running in admin mode.

why does HttpListener be unable to open when the process is not running in admin mode?

If you try to bind to all network interfaces you require admin. You need to bind only localhost to run as regular user.

What bind are you using when you create the WebServer instance?

I bind all network interfaces when create WebServer.

But I wrote a demo like this:
`
//.net core 2.0
using System;
using System.Net;
using System.Net.Sockets;

namespace testnetcore
{
class Program
{
static void Main(string[] args)
{
Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
IPEndPoint lep = new IPEndPoint(IPAddress.Any, 5555);
try
{
socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
socket.Bind(lep);
socket.Listen(1000);
Console.ReadKey();
}
catch (SocketException e)
{
Console.WriteLine(e);
}
}
}
}
//end
`
It does not require admin

So, is embedio possible to run as regular user?
Thank you for your time.

Well, you are just opening a socket. And that's fine as long you don't register to http.sys.

Embedio, as a regular web server, will register the bindings to Windows and http.sys has some rules to allow ports to be open.

Check the following link https://www.codeproject.com/Articles/437733/Demystify-http-sys-with-HttpSysManager

Was this page helpful?
0 / 5 - 0 ratings