c# 再次尝试 连接失败_c# – SignalR“启动请求期间出错.停止连接.“

内部错误

来自Fiddler:

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模拟器,我正在使用集线器,但有些在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

});

标签:c,signalr,signalr-hub,cordova

来源: https://codeday.me/bug/20190702/1357672.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值