Navigation

    SmartAPI Forum
    • Register
    • Login
    • Search
    • Categories
    • Popular
    • Groups
    • FAQs
    • API Docs

    Error info: [Errno 8] nodename nor servname provided, or not known

    Python SDK
    0
    1
    3
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A
      Ad0rable last edited by

      The thing is that, when I going to authenticate using the API, the error shows is this:

      Error info: [Errno 8] nodename nor servname provided, or not known
      [Errno 8] nodename nor servname provided, or not known
      Error info: SmartWebSocket.__on_close() takes 2 positional arguments but 4 were given
      SmartWebSocket.__on_close() takes 2 positional arguments but 4 were given
      

      While the two files which manage the auth and stream of data from the web socket are as follows:

      auth.py

      from SmartApi import SmartConnect
      import config
      
      def authenticate():
          obj = SmartConnect(api_key=config.API_KEY)
          data = obj.generateSession(config.CLIENT_ID, config.PASSWORD, config.TOTP)
      
          refreshToken = data['data']['refreshToken']
      
          feedToken = obj.getfeedToken()
          return obj, refreshToken, feedToken
      

      data_stream.py

      import json
      from SmartApi import SmartWebSocket
      import config
      import auth
      
      def stream(feedToken, clientCode):
          ss = SmartWebSocket(feedToken, clientCode)
          def on_message(ws, message):
              print("Ticks: {}".format(message))
          def on_open(ws):
              print("on open")
              ss.subscribe("mw", config.TOKEN)
          def on_error(ws, error):
              print(error)
          def on_close(ws, close_status_code, close_msg):
              print("### Connection closed ###")
              print(f"Status code: {close_status_code}, Message: {close_msg}")
      
          ss._on_open = on_open
          ss._on_message = on_message
          ss._on_error = on_error
          ss._on_close = on_close
          ss.connect()
      obj, refreshToken, feedToken = auth.authenticate()
      stream(feedToken, config.CLIENT_ID)
      

      It would be great if the issue of mine is resolved at the earliest. Thanks...

      1 Reply Last reply Reply Quote 0
      • First post
        Last post