                            (if (@channel-hub channel)
                              (do
                                (debug "server sending msg:" url (pr-str m))
-                               (if (= (:topic m) :binary-fetched)
-                                 (send! channel ^bytes (let [out (ByteArrayOutputStream.)]
-                                                         (.write out (byte 0))
-                                                         (.write out (:value m))
-                                                         (.toByteArray out)))
-                                 (let [baos (ByteArrayOutputStream. (* 100 1024 1024))
-                                       writer (transit/writer baos :json)]
-                                   (.write baos (byte-array 1 (byte 1)))
-                                   (transit/write writer m)
-                                   (send! channel (.toByteArray baos) #_(str " " (pr-str m))))))
+                               (with-open [baos (ByteArrayOutputStream.)]
+                                 (if (= (:topic m) :binary-fetched)
+                                   (do
+                                     (.write baos (byte 0))
+                                     (.write baos (:value m)))
+                                   (let [writer (transit/writer baos :json)]
+                                     (.write baos (byte-array 1 (byte 1)))
+                                     (transit/write writer m)))
+                                 (send! channel ^bytes (.toByteArray baos))))
                              (debug "dropping msg because of closed channel: " url (pr-str m)))
                            (recur (<! out))))
                        (on-close channel (fn [status]

                                                     (async/put! in (with-meta m {:host host})))

                                                   1
                                                   (let [bais (ByteArrayInputStream. blob)
                                                         reader (transit/reader bais :json)
                                                         m (transit/read reader)]
                                                     (debug "client received transit blob from:"
                                                            url (take 10 (map byte blob)))
                                                     (async/put! in (with-meta m {:host host})))))))))))]
     {:new-conns conns
      :channel-hub channel-hub
      :url url

                       (on-receive channel (fn [data]
                                             (if (string? data)
                                               (do
                                                 (debug "server received string data:" url data)
                                                 (async/put! in
                                                             (with-meta
                                                               (read-string-safe @tag-table data)
