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"?
The solution was:
http://{MyIPAddress}:8080
instead of http://localhost:8080
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With