 ;by default all clients will share this event loop group
 (defonce ^NioEventLoopGroup EVENT-LOOP-GROUP (NioEventLoopGroup. (get-default-threads) (DefaultThreadFactory. "global-netty-nio-events" true)))
 
-(defn close-client [{:keys [^NioEventLoopGroup group ^NioEventLoopGroup read-group ^ChannelFuture channel-f]}]
+(defn close-client [{:keys [^NioEventLoopGroup group ^NioEventLoopGroup read-group ^ChannelFuture channel-f internal-error-ch write-ch]}]
       (let [^Channel channel (.channel channel-f)]
 
            ;only shutdown the event loop groups if they are uniquely created for the connection

   (:require [clojure.tools.logging :refer [info error]]
             [clj-tcp.codec :refer [byte-decoder default-encoder buffer->bytes]]
             [clojure.core.async.impl.protocols :as asyncp]
             [clojure.core.async :refer [chan >!! go >! <! <!! thread timeout alts!! dropping-buffer sliding-buffer]])
   (:import  
            
            [clj_tcp.util PipelineUtil]

		              (do 
                           (write-poison local-client)
			               (.set ^AtomicBoolean (:closed local-client) true)
			               (>!! error-ch [v o])) ;send the error channel)
                (catch Exception e (error e e))))
             (do
		          (if (instance? Poison v)
