Jul*_*Van 5 signalr signalr-hub
我正在使用以下代码创建Signal R自托管服务器:
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);
}
}
}
Run Code Online (Sandbox Code Playgroud)
我还创建了一些通过集线器连接到这个SignalR服务器的客户端应用程序,当我在本地计算机上测试时,一切正常.
但是当我尝试使用域计算机IP地址或计算机名称而不是http://localhost:8080(从域网络的另一台计算机甚至从我的本地计算机)连接到服务器时,我收到错误,因为无法找到服务器.
你能帮我用IP地址而不是"localhost"连接我的SignalR服务器吗?
解决方案是:
http://{MyIPAddress}:8080而不是http://localhost:8080| 归档时间: |
|
| 查看次数: |
10007 次 |
| 最近记录: |