2015年11月20日 星期五

連結SignalR卻遇到「You are using a version of the client that isn't compatible with the server. Client version 1.4, server version 1.3.」 錯誤

server push 在多人系統中是可能會遇到的課題
在這次我們試著用SignalR來實做
大家應該都拿到範例了
如果是要從server的control去呼叫已經存在的SignalR去送訊息,
參考以下的程式碼:(caller project要先安裝siganlR client 套件) 
========先決條件是你已經做好一個SignalR with hub "ChatHub"================
 public ActionResult callSignalR() {
            var hubConnection = new HubConnection("http://localhost/SignalRChat");
            IHubProxy myproxy = hubConnection.CreateHubProxy("ChatHub");
            hubConnection.Start().Wait();
            myproxy.Invoke("Send", "From backend", "Attention!!");
            return new EmptyResult();
        }
===========================================
可是執生起來(hubConnection.start.Wait()那段),居然出現exception:
「You are using a version of the client that isn't compatible with the server. Client version 1.4, server version 1.3.」
翻遍所有的套件,好像都沒有1.4/1.3的代號
是的,問題不出在caller/control,而是出在signalR,
回到SignalR的專案,用nuget把用到的相關的套件做update,這個問題就解決了
就是這麼單純

以上,大家加油吧

沒有留言:

張貼留言