dotnet / WatsonWebserver

Watson is the fastest, easiest way to build scalable RESTful web servers and services in C#.
MIT License
406 stars 83 forks source link

Cant acces server from anywhere but pc its running on #31

Closed maetiskou closed 4 years ago

maetiskou commented 4 years ago

I've successfully created server which works perfectly fine on localhost until i try to connect to it from any other computer in network...

static void Main(string[] args)
        {
            Server server = new Server(_hostname, _port, false, DefaultRoute);
            Database database = new Database();

            server.AccessControl.Mode = AccessControlMode.DefaultPermit;

            for (; ; )
            {
                switch (Console.ReadLine())
                {
                    default:

                        break;
                    case "exit":
                        return;
                }
            }
        }

public static async Task DefaultRoute(HttpContext context)
        {
                context.Response.StatusCode = 200;
                await context.Response.Send("Succesful Request");
                return;
        }

Database class does communication with mysql database stuff..

I've created exception in firewall and i've tried running program with admin privileges..

jchristn commented 4 years ago

Hi @maetiskou on which hostname and which port number are you listening? Are you using an IP address or a hostname for _hostname? When trying to connect from a client, are you using the IP address or hostname? There has to be an explicit match between what you have for hostname and what comes in on the request (this is a restriction in the underlying http.sys).

Administrator is required if you use a port number under 1024, or, if you use * or + as the hostname, which will route any request on any DNS hostname/IP address to this instance (also making it a helpful debugging tool).

Could you try with * or + as the hostname in your constructor?

Thanks, Joel

jchristn commented 4 years ago

Hi @maetiskou did this help you? Cheers

jchristn commented 4 years ago

Please reopen if the issue persists after trying the above.

maetiskou commented 4 years ago

Hi @jchristn i've tried all of the above before as i've seen it in other issues and nothing worked for me.

Nonetheless i am using .Net HttpListener instead as it was just enough to suit my needs..

Problem was for sure somewhere in my network or router settings anyway... But thanks for the help and i am sorry for leaving issue open.