       ^Bootstrap (.handler ^ChannelInitializer (client-channel-initializer conf)))
     (let [ch-f (.connect b)]
       (.sync ch-f)
-      (->Client g ch-f write-ch read-ch internal-error-ch error-ch (AtomicInteger.) (AtomicBoolean. false))))
+      (->Client g ch-f write-ch read-ch internal-error-ch error-ch reconnect-count closed)))
   (catch Exception e (do
                        (.printStackTrace e)
                        (error (str "Error starting client " e) e)
                        (>!! internal-error-ch [e nil])
-                       ))))
+                       )))))
     
 (defn read-print-ch [n ch]
   (go 

    (go 
      (loop [local-client client]
        (let [[v o] (<! internal-error-ch)
              reconnected-count (.get ^AtomicInteger (:reconnect-count client))
              ]
          (error "read error from internal-error-ch " v)
          (if (> reconnect-count retry-limit) ;check reconnect count
             (do ;if the same connection has been reconnected too many times close
               (write-poison local-client)
               (close-all local-client)
               (>! error-ch [v o]) ;send the error channel
               )
             (do
		          (if (instance? Poison v)

  (close-client conf)
  (if group
    (-> group .shutdownGracefully .sync))
  (prn "Close all !!!!!!!!! " (hash (closed)))
   (.set ^AtomicBoolean closed true))


(defn client-handler [{:keys [group read-ch internal-error-ch write-ch]}]
