question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot reach the RestServer other than localhost.

See original GitHub issue

Hello , I am using VS2012 and Grapevine 3.0.4 , when i use the Grapevine same machine with localhost hostname , everything works well. If I want to reach from other PC with client , Server could not be start listening with hostname ip address or Computername

If i try server pc set hostname to localhost , it starts listening but when reached from other PC with IP or name server returns bad request 400

Is it something wrong with my code or library.

My Server code is public class embeddedHTTP // {

    private RESTServer Server;

    public void ServerStart()
    {

        try
        {

            Server = new RESTServer();
            Server.Port =  GlobalVars.HttpHostPort;
            Server.Host = GlobalVars.HttpHostAdress; // THIS ONLY WORKS FOR LOCALHOST
            Server.MaxThreads = 20;
            Server.Start();


            while (Server.IsListening)
            {
                Thread.Sleep(GlobalVars.HttpHostRespTime);
            }
        }

        catch (Exception ex)
        {
            messenger.logque("embedded HTTP server not started, Error ID : 52", 3, null);

        }

    }

    public void ServerStop()
    {


        Server.Stop();
    }


    public sealed class MyResource : RESTResource
    {

        //d+$^  [a-zA-Z]+
        [RESTRoute(Method = Grapevine.HttpMethod.GET, PathInfo = @"/")] 
        public void HandleFooRequests(HttpListenerContext context)
        {

       //     String RawuR = context.Request.RawUrl;
            String URL = Convert.ToString(context.Request.Url);
            String ResultXML = brain.HTTPCMD(URL);          
            this.SendTextResponse(context, ResultXML);

        }


     }


    }

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
MiaoDXcommented, Oct 9, 2017

Just a small note on this, in case someone needs one simple example (4.x version):


using (var server = new RestServer())
{
    server.Host = "*";
    server.Port = "1024";

    server.LogToConsole().Start();
    Console.ReadLine();
    server.Stop();
}

However, run this in VS directly will encouter errors:

Exception thrown: 'Grapevine.Exceptions.Server.UnableToStartHostException' in Grapevine.dll
An unhandled exception of type 'Grapevine.Exceptions.Server.UnableToStartHostException' occurred in Grapevine.dll
Additional information: An error occured when trying to start the Grapevine.Server.RestServer

The simplest and cleanest way (in my opinion) is do as @jimmyland pointed out, run it in command line but with admin privileges.

1reaction
jimmylandcommented, Apr 13, 2016

Maybe try the following:

When you create the new RESTServer(…), the first argument (hostname) can be “*”

Of course check the firewall settings and ensure you’ve opened the port you’re running the server on

Either run the server as admin, or open a terminal as admin and run “netsh http add urlacl url=http://*:1234/ user=Everyone” (where 1234 should be whatever port you’re running on)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot reach the RestServer other than localhost. · Issue #35
Hello , I am using VS2012 and Grapevine 3.0.4 , when i use the Grapevine same machine with localhost hostname , everything works...
Read more >
Hyperledger REST Server Angular Web App getting could ...
Problem arise when I try to use the application outside of localhost. I can access the REST Server on port 3000 and interact...
Read more >
404 - Page cannot be found when access rest api throught ...
it was http://[pc-name]:port , but it worked fine when i used localhost:port, just cannot browse to _api/web, the original url aslo.
Read more >
Localhost REST service cannot connect
Hi,. I have a local rest service (node.js) running on port 3000 on my developer machine (localhost). I would like to get my...
Read more >
Could not connect to server: http://localhost:8087
Hello, I have the user name and password when setup/install correct, but when trying to login to Wowza Streaming Engine Manager I get...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found