Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SignalR: Cannot connect to http://localhost:8080 self-hosted server using the full IP address

I'm creating a Signal R self-hosted server using the following code:

internal class Config
{
    internal static string serverurl = null;
    internal static Microsoft.AspNet.SignalR.HubConfiguration hubconfiguration = null;
    internal static SignalRHub Hub { get; set; }
    internal static void StartServer()
    {
        serverurl = "http://localhost:8080";
        // In this method, a web application of type Startup is started at the specified URL (http://localhost:8080). 
        {
            Microsoft.Owin.Hosting.WebApp.Start<Startup>(serverurl);
            Log.AddMessage("Server running on " + serverurl); 
        }
        catch(Exception ex)
        {
            Log.AddMessage("An error occurred when starting Server: " + ex);
        }
    }
}

class Startup
{
    // the class containing the configuration for the SignalR server 
    // (the only configuration is the call to UseCors), 
    // and the call to MapSignalR, which creates routes for any Hub objects in the project.
    public void Configuration(IAppBuilder app)
    {
        try
        {
            app.UseCors(CorsOptions.AllowAll);
            // Enable detailed errors when an exception occures
            Config.hubconfiguration = new HubConfiguration();
            Config.hubconfiguration.EnableDetailedErrors = true;

            app.MapSignalR("/signalr", Config.hubconfiguration);
        }
        catch(Exception ex)
        {
            Log.AddMessage("An error occurred during server configuration: " + ex.Message);
        }
    }
}

I also created some client applications connecting to this SignalR server via a hub, and everything is working fine when I'm testing on my local computer.

But when I try to connect to the server using the domain computer IP address or the computer name instead of http://localhost:8080 (from another computer of the domain network or even from my local computer), I'm getting an error as the server cannot be found.

Can you please help me to connect to my SignalR server using the IP address instead of "localhost"?

like image 622
JulienVan Avatar asked Aug 19 '14 12:08

JulienVan


1 Answers

The solution was:

  1. Setting the server url to http://{MyIPAddress}:8080 instead of http://localhost:8080
  2. Opening the port 8080 by adding a new TCP inbound rule in the Windows Firewall
like image 76
JulienVan Avatar answered Oct 29 '22 17:10

JulienVan