     (message (cond-> (js->clj msg :keywordize-keys true)
                http-url (assoc :http-url http-url)))))
 
-(defn fill-url-template [websocket-url']
+(defn fill-url-template [connect-url']
   (if (= host-env :html)
-      (-> websocket-url'
+      (-> connect-url'
           (string/replace "[[client-hostname]]" js/location.hostname)
           (string/replace "[[client-port]]" js/location.port))
-      websocket-url'))
+      connect-url'))
+
+(defn make-url [connect-url']
+  (doto (guri/parse (fill-url-template (or connect-url' connect-url)))
+    (.setQueryData (cond-> (.add (QueryData.) "fwsid" (or (session-id) (random-uuid)))
+                     (session-name) (.add "fwsname" (session-name))))))
 
 (defn connect [& [websocket-url']]
   ;; TODO take care of forwarding print output to the connection
   (let [websocket (goog.net.WebSocket.)
-        url (str (fill-url-template (or websocket-url' websocket-url))
-                 (when-let [n (session-name)]
-                   (str "?figwheelReplSessionName=" n)))]
+        url (str (make-url websocket-url'))]
     (patch-goog-base)
     (doto websocket
       (.addEventListener goog.net.WebSocket.EventType.MESSAGE

  (connections-available re)

  (evaluate re "44")

  scratch
  *connections*

  (:import
   #?@(:cljs [goog.net.WebSocket
              goog.debug.Console
              [goog.Uri QueryData]
              [goog Promise]
              [goog.storage.mechanism HTML5SessionStorage]]
       :clj [java.util.concurrent.ArrayBlockingQueue])))
