From 3e55aef25a45176b35ce6d7d5664d1a035571fe6 Mon Sep 17 00:00:00 2001 From: Henry Oswald Date: Fri, 31 Jul 2015 15:42:47 +0100 Subject: [PATCH 1/2] show error if socket io fails to connect. Not tested yet. --- services/web/app/views/project/editor.jade | 4 +++- .../public/coffee/ide/connection/ConnectionManager.coffee | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/services/web/app/views/project/editor.jade b/services/web/app/views/project/editor.jade index 0ccdcd88f4..18e88b6620 100644 --- a/services/web/app/views/project/editor.jade +++ b/services/web/app/views/project/editor.jade @@ -13,7 +13,9 @@ block content h3 #{translate("loading")}... .progress .progress-bar(style="width: 20%", ng-style="{'width': state.load_progress + '%'}") - p.text-center.text-danger(ng-if="state.error").ng-cloak {{ state.error }} + p.text-center.text-danger(ng-if="state.error").ng-cloak + span(ng-bind-html="state.error") + .global-alerts(ng-cloak) .alert.alert-danger.small(ng-if="connection.forced_disconnect") diff --git a/services/web/public/coffee/ide/connection/ConnectionManager.coffee b/services/web/public/coffee/ide/connection/ConnectionManager.coffee index 9aa0513b09..40ea21f5a7 100644 --- a/services/web/public/coffee/ide/connection/ConnectionManager.coffee +++ b/services/web/public/coffee/ide/connection/ConnectionManager.coffee @@ -39,6 +39,13 @@ define [], () -> @joinProject() , 100) + @ide.socket.on "connect_failed", () => + @connected = false + $scope.$apply () => + @$scope.state.error = "Unable to connect, please view the connection problems guide to fix the issue." + + + @ide.socket.on 'disconnect', () => @connected = false @ide.pushEvent("disconnected") From 89256f9d5fcff6f79bb70a9ea51f6e6ee3cb1ce3 Mon Sep 17 00:00:00 2001 From: Henry Oswald Date: Mon, 5 Oct 2015 00:43:37 +0100 Subject: [PATCH 2/2] added connect timeout option to socket.io.connect needed for the firing of connect_failed. Best way to test is drop connect timeout to 10ms and remove some transports from realtime. --- .../web/public/coffee/ide/connection/ConnectionManager.coffee | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/services/web/public/coffee/ide/connection/ConnectionManager.coffee b/services/web/public/coffee/ide/connection/ConnectionManager.coffee index 40ea21f5a7..49774416e8 100644 --- a/services/web/public/coffee/ide/connection/ConnectionManager.coffee +++ b/services/web/public/coffee/ide/connection/ConnectionManager.coffee @@ -24,6 +24,7 @@ define [], () -> @ide.socket = io.connect null, reconnect: false + 'connect timeout': 30 * 1000 "force new connection": true @ide.socket.on "connect", () => @@ -42,7 +43,7 @@ define [], () -> @ide.socket.on "connect_failed", () => @connected = false $scope.$apply () => - @$scope.state.error = "Unable to connect, please view the connection problems guide to fix the issue." + @$scope.state.error = "Unable to connect, please view the connection problems guide to fix the issue."