SignalR - WebSocket错误:网络错误12030,与服务器的连接异常终止

问题描述 投票:1回答:2

试图让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">

在web配置中设置

本地信号记录:

[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连接,它也不会触发相应的集线器响应。

asp.net vb.net iis websocket signalr
2个回答
0
投票

在我的家庭连接上尝试网站后,我发现它连接到websockets很好。

所以我假设我的“工作”电脑和网络服务器之间有某种代理服务器。其中我无法访问。 (假设代理服务器通过防火墙)。

[GMT + 0000(GMT标准时间)10:33:15] SignalR:客户订阅了hub'notificationhub'。

[GMT + 0000(GMT标准时间)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传输开始。 [十点33分16秒GMT + 0000(GMT标准时间)] 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传输。启动启动请求。 [GMT + 0000(GMT标准时间)10:33:16] SignalR:开始请求成功。转换到连接状态。 [10:33:16 GMT + 0000(GMT标准时间)] SignalR:现在监控保持活动,警告超时为13333.333333333332,保持活动超时20000并断开30000集线器启动的超时,连接ID = 7f3eba16-9e7b-450e- A740-a69fa91047b6


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;
© www.soinside.com 2019 - 2024. All rights reserved.