问题
In both a C# client and Web Client - how do I tell signalR - "Try everything but websockets"?
I have the following in my web code:
window.hubReady = $.connection.hub.start({ transport: 'longPolling' });
But this is just javascript and longpolling; I'm looking for the configuration for both JS and C# clients to only remove websockets as a transport. How can this be done?
回答1:
On the server:
public class Startup
{
public void Configuration(IAppBuilder app)
{
DisableWebSockets(GlobalHost.DependencyResolver);
HubConfiguration hubConfiguration = new HubConfiguration();
hubConfiguration.EnableDetailedErrors = true;
app.MapSignalR(hubConfiguration);
}
public static void DisableWebSockets(IDependencyResolver resolver)
{
var manager = resolver.Resolve<ITransportManager() as TransportManager;
manager.Remove("webSockets");
}
}
On the client:
$.connection.hub.start({ transport: ['serverSentEvents', 'foreverFrame', 'longPolling'] }).done(function () {...}
Edit - adding bracket
来源:https://stackoverflow.com/questions/42738840/signalr-how-to-disable-websockets-but-keep-other-transports-active