title: Zerodha KiteConnect API producing 1006 Error
body: <p>I am building a dashboard for live tickers</p>
  <p>I am using zerodha Kiteconnect to fetch SE Options &amp; Futures live data for that ... The client for whom I am building the dashboard has provided me the api key, and also provides me the access token daily .... The situation is he uses the same credentials in his own program (that he runs separately in his own laptop) to fetch live ticker data</p>
  <p>When I use KiteConnect to fetch instrument dump it works,  below code executes successfully,</p>
  <pre class="lang-py prettyprint-override"><code>  
     from kiteconnect import KiteTicker, KiteConnect
  
     access_token = '*********' # changes every day
     api_key = '*********'
  
     kite = KiteConnect(api_key=key_secret, access_token = access_token)
     instrument_list = kite.instruments(exchange=kite.EXCHANGE_NFO)
  
  </code></pre>
  <p>but when I use KiteTicker (WebSocket Streaming) with same credentials as shown in <strong>code below it produces 1006 Connection error</strong>:</p>
  <pre class="lang-py prettyprint-override"><code>kws = KiteTicker(api_key, access_token=kite.access_token)
  
  ####### define the callbacks ############
  
  def on_connect(ws, response):
      # Callback on successful connect.
      # Subscribe to a list of instrument_tokens (RELIANCE and ACC here).
      ws.subscribe(instrument_tokens)
  
      # Set tick in `full` mode.
      ws.set_mode(ws.MODE_FULL, instrument_tokens)
  
  
  def on_ticks(ws, ticks):
      # Callback to receive ticks.
      # logging.debug(&quot;Ticks: {}&quot;.format(ticks))
      print(ticks)
      ticks_list.append(ticks)
  
      # close the connection after some time
      if (time.time() - begin_time) &gt; 120: # run for 2 minutes
          write_json(ticks_list)
          print(&quot;close called&quot;)
          ws.close()
  
  
  def on_close(ws, code, reason):
      # On connection close stop the event loop.
      # Reconnection will not happen after executing `ws.stop()`
      print(&quot;-------- Stopping ------------&quot;)
      ws.stop()
      print(&quot;--------- Stopped ----------&quot;)
  
  
  ### define
  ticks_list = [] # will hold list of JSON objects
  ##### Assign the callbacks.
  kws.on_ticks = on_ticks
  kws.on_connect = on_connect
  kws.on_close = on_close
  
  begin_time = time.time()
  
  # Infinite loop on the main thread. Nothing after this will run.
  # You have to use the pre-defined callbacks to manage subscriptions.
  kws.connect()
  
  </code></pre>
  <p>The exact error produced is:</p>
  <blockquote>
  <p>Connection error: 1006 - connection was closed uncleanly (I dropped the WebSocket TCP connection: close reason without close code)</p>
  </blockquote>
  <p>Can you please guide me as to why is this happening? Also <strong>is it possible to use the same credentials in parallel by two different programs from different IP</strong> to fetch live tick data...</p>
  <p>Thanks</p>