尝试让SignalR在Web服务器上运行(IIS 8,Server 2012,安装了websockets,.NET 4.5),但没有任何乐趣。
在我的本地IIS(Windows 8并使用websockets连接)上运行良好
<httpRuntime targetFramework="4.5"/>
和
<compilation strict="false" explicit="true" targetFramework="4.5" debug="false">
在webconfig中设置
本地信号记录:
[11:26:17 GMT+0000 (GMT Standard Time)] SignalR: Client subscribed to hub 'notificationhub'.
[11:26:17 GMT+0000 (GMT Standard Time)] SignalR: Negotiating with '/signalr/negotiate?clientProtocol=1.5&connectionData=%5B%7B%22name%22%3A%22notificationhub%22%7D%5D'.
[11:26:17 GMT+0000 (GMT Standard Time)] SignalR: webSockets transport starting.
[11:26:17 GMT+0000 (GMT Standard Time)] SignalR: Connecting to websocket endpoint 'ws://localhost:22038/signalr/connect?transport=webSockets&clientProtocol=1.5&connectionToken=W5PmClxV6R32xJpuP5It2NUDVvJXOESGJCrgQYb67z59ODUJFr13zQzgBgTYEfmr4XbgMmRGU3ZncQS3yZU2Hmh%2Fc3h%2F17fh9gRlUOUdnaVYcnls%2BQon%2F7R0ckNw8MnLcrG1pg%3D%3D&connectionData=%5B%7B%22name%22%3A%22notificationhub%22%7D%5D&tid=3'.
[11:26:17 GMT+0000 (GMT Standard Time)] SignalR: Websocket opened.
[11:26:17 GMT+0000 (GMT Standard Time)] SignalR: webSockets transport connected. Initiating start request.
[11:26:18 GMT+0000 (GMT Standard Time)] SignalR: The start request succeeded. Transitioning to the connected state.
[11:26:18 GMT+0000 (GMT Standard Time)] SignalR: Now monitoring keep alive with a warning timeout of 13333.333333333332, keep alive timeout of 20000 and disconnecting timeout of 30000
hub start, connection id=01b7a623-5531-496c-a5e1-ab0876e2c1a6
服务器日志:
[11:24:01 GMT+0000 (GMT Standard Time)] SignalR: Client subscribed to hub 'notificationhub'.
[11:24:01 GMT+0000 (GMT Standard Time)] SignalR: Negotiating with '/signalr/negotiate?clientProtocol=1.5&connectionData=%5B%7B%22name%22%3A%22notificationhub%22%7D%5D'.
[11:24:02 GMT+0000 (GMT Standard Time)] SignalR: webSockets transport starting.
[11:24:02 GMT+0000 (GMT Standard Time)] SignalR: Connecting to websocket endpoint 'ws://foo.co.uk/signalr/connect?transport=webSockets&clientProtocol=1.5&connectionToken=uibfnMomSreytNZY7UiusFWoTjNWO6%2FNIaBzIM%2FVVSBOXk6SNlyULUH%2FaGWoPynoEbx6sKRfShJG0zrd846uqgdgEK6xQIP2K5j3xfwtBlngGG3i6k%2FYoHNk5subReA3TsCxfw%3D%3D&connectionData=%5B%7B%22name%22%3A%22notificationhub%22%7D%5D&tid=10'.
[11:24:03 GMT+0000 (GMT Standard Time)] SignalR: Websocket opened.
SCRIPT12030: WebSocket Error: Network Error 12030, The connection with the server was terminated abnormally
[11:24:03 GMT+0000 (GMT Standard Time)] SignalR: Unclean disconnect from websocket: [no reason given].
[11:24:03 GMT+0000 (GMT Standard Time)] SignalR: Closing the Websocket.
[11:24:03 GMT+0000 (GMT Standard Time)] SignalR: webSockets transport failed to connect. Attempting to fall back.
[11:24:03 GMT+0000 (GMT Standard Time)] SignalR: serverSentEvents transport starting.
[11:24:03 GMT+0000 (GMT Standard Time)] SignalR: This browser doesn't support SSE.
[11:24:03 GMT+0000 (GMT Standard Time)] SignalR: serverSentEvents transport failed to connect. Attempting to fall back.
[11:24:03 GMT+0000 (GMT Standard Time)] SignalR: foreverFrame transport starting.
[11:24:03 GMT+0000 (GMT Standard Time)] SignalR: Binding to iframe's load event.
[11:24:03 GMT+0000 (GMT Standard Time)] SignalR: Iframe transport started.
[11:24:03 GMT+0000 (GMT Standard Time)] SignalR: foreverFrame transport connected. Initiating start request.
[11:24:03 GMT+0000 (GMT Standard Time)] SignalR: The start request succeeded. Transitioning to the connected state.
[11:24:03 GMT+0000 (GMT Standard Time)] SignalR: Now monitoring keep alive with a warning timeout of 13333.333333333332, keep alive timeout of 20000 and disconnecting timeout of 30000
hub start, connection id=cd2af7f4-5f85-40bb-a0a6-f8f8060bedae
即使它似乎使用foreverFrame连接,它也不会触发相应的集线器响应。
答案 0 :(得分:0)
在家庭连接上尝试网站后,我发现它连接到websockets很好。
所以我假设我的“工作”电脑和网络服务器之间有某种代理服务器。其中我无法访问。 (假设代理服务器通过防火墙)。
[格林尼治标准时间+00:00(格林尼治标准时间标准时间)10:33:15] SignalR:客户订阅 枢纽'notificationhub'。
[格林尼治标准时间+00:00(格林威治标准时间标准时间)10:33:15] SignalR:与...谈判 '/signalr/negotiate?clientProtocol=1.5&connectionData=%5B%7B%22name%22%3A%22notificationhub%22%7D%5D'。 [GMT + 0000(GMT标准时间)10:33:16] SignalR:webSockets传输 开始。 [GMT + 0000(GMT标准时间)10:33:16] SignalR:正在连接 到websocket端点 “WS://嗒嗒/ signalr /连接运输=的WebSockets&安培; clientProtocol = 1.5&安培; connectionToken = IxxvgxBhvbsruv2uk0pK%2FPB708bJGvoOJD0oR0vVPgBip%2B7uGy68HEMOw1ikq7%2BuiyX7XqN%2FwYK%2BKgkrBlz9HHuI5HSDQEwRHvSr2Ey1pg2B7FaviRLFcNu8mg2dRWHVKbAkdw%3D%3D&安培; connectionData =%5B%7B%22name%22%3A %22notificationhub%22%7D%5D&安培; TID = 6' 。 [GMT + 0000(GMT标准时间)10:33:16] SignalR:Websocket打开了。 [GMT + 0000(GMT标准时间)10:33:16] SignalR:webSockets传输 连接的。启动启动请求。 [格林威治标准时间10:33:16 + 0000(格林威治标准时间标准 时间)] SignalR:启动请求成功。过渡到 连通状态。 [GMT + 0000(GMT标准时间)10:33:16] SignalR:现在 监控保持活动,警告超时为13333.333333333332, 保持活动超时20000并断开30000集线器的超时 开始,连接ID = 7f3eba16-9e7b-450e-a740-a69fa91047b6
答案 1 :(得分:0)
如果服务器上存在JSON序列化问题,则可能会出现此类非描述性错误。对于大多数正常的异常,我希望有一个适当的例外。
在我的情况下,我犯了一个非常愚蠢的错误,并且在我的返回消息(服务器端)中有两个具有相同JsonProperty名称的属性。基本上是一个剪切和粘贴错误需要一段时间才能被注意到,因为'SuggestedCities'不会总是被填充。
public class ValidateZipStateResponse
{
[JsonProperty("correctedCity")]
public string CorrectedCity { get; set; }
[JsonProperty("correctedState")]
public string CorrectedState { get; set; }
[JsonProperty("correctedState")]
public string[] SuggestedCities { get; set; }
}
确保客户端启用调试。它对这个错误没有帮助,但总的来说它非常有用,你会在浏览器控制台中看到一个有用的日志。
$.connection.hub.logging = true;