     last_ping_time = ''
 
 salvus_client.on "connecting", () ->
-    $(".salvus-connection-status-disconnected").hide()
-    $(".salvus-connection-status-connected").hide()
-    $(".salvus-connection-status-connecting").show()
-    $(".salvus-fullscreen-activate").hide()
-    $(".salvus-connection-status-ping-time").html('')
-    last_ping_time = ''
-    $("a[href=#salvus-connection-reconnect]").find("i").addClass('fa-spin')
+    f = ->
+        $(".salvus-connection-status-disconnected").hide()
+        $(".salvus-connection-status-connected").hide()
+        $(".salvus-connection-status-connecting").show()
+        $(".salvus-fullscreen-activate").hide()
+        $(".salvus-connection-status-ping-time").html('')
+        last_ping_time = ''
+        $("a[href=#salvus-connection-reconnect]").find("i").addClass('fa-spin')
+        network_connect_timer = null
+
+    # insert delay mainly on connected → connecting state transitions
+    # such that there are brief&flaky "connecting" warnings.
+    if network_connect_state != 'connecting'
+        if not network_connect_timer?
+            network_connect_timer = window.setTimeout(f, 2000)
+    network_connect_state = 'connecting'
 
 salvus_client.on "connected", () ->
+    network_connect_state = 'connected'
+    network_connect_timer_stop()
     $(".salvus-connection-status-disconnected").hide()
     $(".salvus-connection-status-connecting").hide()
     $(".salvus-connection-status-connected").show()


last_ping_time = ''

salvus_client.on "disconnected", (state) ->
    state ?= "disconnected"
    $(".salvus-connection-status-connected").hide()
    $(".salvus-connection-status-connecting").hide()
    $(".salvus-connection-status-disconnected").html(state)

        $(".salvus-fullscreen-activate").show()
    $("a[href=#salvus-connection-reconnect]").find("i").removeClass('fa-spin')

ping_time_smooth = null
salvus_client.on "ping", (ping_time) ->
    last_ping_time = ping_time
    ping_time_smooth ?= ping_time
    # reset outside 3x
    if ping_time > 3 * ping_time_smooth or ping_time_smooth > 3 * ping_time
        ping_time_smooth = ping_time
    else
        decay = 1 - Math.exp(-1)
        ping_time_smooth = decay * ping_time_smooth + (1-decay) * ping_time
    $(".salvus-connection-status-ping-time").html("#{Math.floor(ping_time_smooth)}ms")

show_connection_information = () ->
    dialog = $(".salvus-connection-info")
