How to make connection from javascript file

bhumi
I have previously used kiteconnect.php file to make connection; Where I have made one php page to get the request token and to achieve this i have set this page as a Request URL.

Now , I want to make connection from javascript file. Please guide how I can proceed.
  • Vivek
    You can check this ticker version written for pure js to be used in frontend - https://gist.github.com/ajinasokan/b36d17da1a58af62782978c16bca309a
  • bhumi
    Yes, I have integrated the same but facing following issue on testing at Firefox browser:

    Firefox can’t establish a connection to the server at wss://websocket.kite.trade/?api_key=XXXXX&user_id=XXXX&public_token=XXXX&uid=XXXXX.
  • bhumi
    @vivek , now I have resolved above mentioned issue by updating:

    "wss://websocket.kite.trade/" to "ws://websocket.kite.trade/".

    But after that "SecurityError: The operation is insecure." issue is coming; and no script is running after that. Please guide !!
  • Vivek
    Since you running from non SSL site you are getting security error.
  • bhumi
    we are running from https:// URL.
    To avoid "Firefox can’t establish a connection to the server", I have updated wss to ws.
    Please guide how can we proceed to get the tick data.
  • bhumi
    bhumi edited June 2018
    @vivek please guide or suggest to proceed.

    Still Websocket connection is not established.
  • Vivek
    @bhumi For now we have disable CORS so you wont be able to use this directly. You may have to use a proxy server such as nginx which will proxy websocket connection to ws.kite.trade from your domain. You can read about proxying here - https://www.nginx.com/blog/websocket-nginx/
Sign In or Register to comment.