C# 信号服务404集线器
我在一个简单的Windows服务应用程序中安装了信号器主机C# 信号服务404集线器,c#,windows-services,signalr,C#,Windows Services,Signalr,我在一个简单的Windows服务应用程序中安装了信号器主机 protected override void OnStart(string[] args) { const string url = "https://localhost:8080"; AppDomain.CurrentDomain.Load(typeof(MyHub).Assembly.FullName); using (WebApp.Start<Startup>(url)) {
protected override void OnStart(string[] args)
{
const string url = "https://localhost:8080";
AppDomain.CurrentDomain.Load(typeof(MyHub).Assembly.FullName);
using (WebApp.Start<Startup>(url))
{
Log(string.Format("Device Hub started on {0}", url));
}
}
信号器似乎启动了,但我在https://localhost:8080/signalr/hubs
。我认为它可能无法识别中心,但我不太清楚如何注册它。有什么建议吗
**这段代码在运行控制台应用程序时起作用,但现在似乎失败了,因为它是通过服务访问的**配置如何: 出于好奇:集线器是否只与HTTP一起工作?(没有SSL?)
编辑:更改
https://localhost:8080
至https://127.0.0.1:8080
然后重试。您可能需要检查以下内容:
它不像http或https+IIS那么简单
更新
好的,我仔细阅读了它,我认为您有一个重大错误,您正在使用(…)块调用中的Start
方法,这意味着您立即关闭主机(启动OnStart
方法退出)。使用(…)
块删除您的,它应该可以工作(我用http测试了它)
此外,鉴于项目中引用了MyHub
,因此根本不需要AppDomain
之类的东西。将连接字符串上的端口更改为443,如下所示
const string url = "https://localhost:443";
或者不使用ssl
const string url = "http://localhost:8080";
hub目前在控制台应用程序中通过HTTP和Https工作,但hub是否仅通过HTTP从Windows服务工作?Windows服务运行的帐户是什么?@Wasp,不,它不是。@martin该服务是作为本地系统运行的。我不认为错误与HTTP/Https有关,我认为它更直接地针对该服务,托管SignalR的主机无法在引用文件中找到集线器。这就成功了!我花了这么长时间在这个问题上,我知道它必须是一些简单的,我忽略了!非常感谢。
const string url = "http://localhost:8080";