启动请求时出现错误.停止连接."

本文关键字:连接 quot 错误 请求 启动 | 更新日期: 2023-09-27 18:16:42

内部错误从小提琴手:

The ConnectionId is in the incorrect format.

从跟踪:

SignalR.Transports.TransportHeartBeat Information: 0 : Connection 75e8d0ef-
64e2-463e-935d-a16759d948f1 is New.
SignalR.HubDispatcher Information: 0 : Failed to process connectionToken yhoTZnFsEnKUbd1/67eByQPhUb 3xkOsYMBXLLvp8nI29NnXrJE5zqHoFgLtA2VxOUJMAOreX6 7FGK4cGbal446Gs5YiV9F8MBduVMEXooL9fSeGpPHThvw56p6CzGX2yNmy7sy014gnak9l3BlZw==: System.FormatException: Invalid length for a Base-64 char array or string.
   at System.Convert.FromBase64_Decode(Char* startInputPtr, Int32 inputLength, Byte* startDestPtr, Int32 destLength)
   at System.Convert.FromBase64CharPtr(Char* inputPtr, Int32 inputLength)
   at System.Convert.FromBase64String(String s)
   at Microsoft.AspNet.SignalR.Infrastructure.DataProtectionProviderProtectedData.Unprotect(String protectedValue, String purpose)
   at Microsoft.AspNet.SignalR.PersistentConnection.TryGetConnectionId(HostContext context, String connectionToken, String& connectionId, String& message, Int32& statusCode)

这是一个来自Apache Cordava App (Visual Studio)的客户端调用,使用ripple模拟器,我正在使用hub,但在PersistentConnection上失败了

http://localhost:4400/ripple/xhr_proxy?tinyhippos_apikey=ABC&tinyhippos_rurl=http%3A//localhost%3A52374/signalr/abort%3Ftransport%3DwebSockets%26clientProtocol%3D1.5%26connectionToken%3D6FHV%252BT%252F0WSoC3R8EEaseIe2481KxD24%252Fa31Toitf9kqUmIZw4jd87DgBnLWtVbLDZkZJA5gnEhQAUchyECh78738dIpuhqy1W4hAEVut%252F0gHr1Ou5bmpWbRi29sqRpwA4Y7Wc4WJPjYMpRIemgzP9w%253D%253D%26connectionData%3D%255B%257B%2522name%2522%253A%2522messagehub%2522%257D%255D HTTP/1.1
Host: localhost:4400
我代码:

$.connection.hub.url = rooturl + "/signalr";
var chat = $.connection.messageHub;
$.connection.hub.start().done(function () {
                       $.connection.hub.disconnected(function () {
                           console.log('signlar connection abort');
                       });
                   }).fail(function (a) {
                       console.log('not connected' + a);
                   });

启动请求时出现错误.停止连接."

我在使用Ripple模拟器时遇到了同样的错误,并通过以下操作设法解决了这个问题:

1:在客户端启用JSONP,修改如下

 $.connection.hub.start()

 $.connection.hub.start({ jsonp: true })

2。在启动

期间的Configuration方法中启用服务器上的JSONP(在我的情况下是c#)
app.MapSignalR(new HubConfiguration
        {
            EnableJSONP = true,
            EnableJavaScriptProxies = true,
            EnableDetailedErrors = true
        });
相关文章: