SignalR with Web Sockets

后端 未结 4 736
耶瑟儿~
耶瑟儿~ 2020-12-08 06:56

I am attempting to get websockets working in my dev environment:

  • Visual Studio 2010
  • Windows 7
  • Signal R 0.51
  • Latest Chrome / Firefox<
4条回答
  •  失恋的感觉
    2020-12-08 07:44

    Signal R does work also on Windows 7, IIS 7.5 and Visual Studio 2012. The only drawback is that it will use longPolling as transport protocol.

    In order to succesfully use signalR with the above configuration we need to set up few things, which actually are not detailed in any of the signalR tutorials.

    So, on server side (win 7, IIS 7.5) when you create the connection and the proxy you must do something like this:

    Connection = new HubConnection('someUrl', false);   
    Proxy = Connection.CreateHubProxy('myHubProxy');   
    Connection.Start(new LongPollingTransport()).Wait(); // notice the specification of transport
    

    Of course, on the client side in the same way you have to specify the transport protocol as being 'longPooling':

    var connection = $.hubConnection('myUrl', { useDefaultPath: false });
    connection.start({ transport: ['websockets', 'longPolling'], jsonp: true, xdomain: true })
    

提交回复
热议问题