                                (connection-established! url)
                                (swap! state assoc :connection {:websocket websocket})
                                (hook-repl-printing-output! {:websocket websocket})))
+          (.addEventListener goog.net.WebSocket.EventType.CLOSED
+                             (fn [e] (connection-closed! url)))
           (.open url))))))
 
 ;; -----------------------------------------------------------

           (msg-fn msg)
           (long-poll msg-fn connect-url'))
         (fn [e] ;; lost connection
           (http-connect connect-url'))))

(defn http-connect* [attempt connect-url']

           (msg-fn msg)
           (js/setTimeout #(poll msg-fn connect-url') 500))
         (fn [e] ;; lost connection
           (connection-closed! connect-url')
           (http-connect connect-url'))))

(defn long-poll [msg-fn connect-url']
