我試圖用signalr集線器連接,但我發現了以下錯誤在javascript:SignalR - WebSocket的握手過程中的錯誤:意外的響應代碼:504
WebSocket connection to 'ws://dev:777/signalr/connect?transport=webSockets&clientProtocol=1.5&connectionToken=%2BRUC9XodaU4R3Wn3BSLfhZXxLqeLj9fp4XlLJSsxrc36dFuEo6O9GOIGYMdsgSeswY2DTzzJe9qCe9JnqgjwusbYROxjkY%2B6d9FD4MVpox4FLEqNzCF5Y%2BOqrY5ndNs%2FRl7aOoKIYelpGmerXj4mdw%3D%3D&connectionData=%5B%7B%22name%22%3A%22machinehub%22%7D%5D&tid=5' failed: Error during WebSocket handshake: Unexpected response code: 504
,然後在控制檯
Could not connect. Invocation of StartMachine failed. Error: No transport could be initialized successfully. Try specifying a different transport or none at all for auto initialization.
我使用這樣的代碼,從轂調用我的方法,其中:
self.Run = function (action, parameters, callbacks) {
try {
var connection = $.hubConnection();
connection.logging = self.Debug;
var hub = connection.createHubProxy(self.Name);
registerConnectionEvents(connection);
registerEvents(hub, callbacks);
connection.start({ transport: ['webSockets'] })
.done(function() {
self.debug("Now connected!");
hub.invoke.apply(hub, $.merge([action], parameters)).fail(function (error) {
var msg = 'Invocation of ' + action + ' failed. ' + error;
self.debug(msg);
});
})
.fail(function (error) {
var msg = 'Could not connect. Invocation of ' + action + ' failed. ' + error;
self.debug(msg);
});
return true;
}
當我運行我與SIG MVC5應用在Visual Studio中的一切都很好。在Windows Server 2012上發佈到IIS8後,它無法通過信號r中的Web套接字進行連接。我試圖關閉兩個防火牆進行測試,但沒有成功。你能幫我解決這個問題嗎?當然,我在該頁面上讀取了一些數據https://docs.microsoft.com/en-us/aspnet/signalr/
我已經安裝了WebSocket協議,但我的信號r只適用於長池的代理代理。我不知道爲什麼websocket正在重置。 –
@MarekBar你使用什麼瀏覽器?安裝websocket後,你嘗試重新啓動服務器?這不應該是必要的,但我們永遠不知道...... – Alisson