Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

socket connection issue - not able to get live data #179

Open
Nishanth009 opened this issue Dec 31, 2024 · 0 comments
Open

socket connection issue - not able to get live data #179

Nishanth009 opened this issue Dec 31, 2024 · 0 comments
Assignees

Comments

@Nishanth009
Copy link

Not able to connect to socket to retrieve live price feed

Error log:-

Traceback (most recent call last):
  File "/stream/fetch_data.py", line 44, in <module>
    api.ws_connect()
  File "/.venv/lib/python3.12/site-packages/breeze_connect/breeze_connect.py", line 56, in ws_connect
    self.sio_handler.connect()
  File "/.venv/lib/python3.12/site-packages/breeze_connect/breeze_connect.py", line 21, in connect
    self.sio.connect(self.hostname, headers={"User-Agent": "python-socketio[client]/socket"}, auth=auth, transports="websocket", wait_timeout=3)
  File "/.venv/lib/python3.12/site-packages/socketio/client.py", line 159, in connect
    raise exceptions.ConnectionError(exc.args[0]) from None
socketio.exceptions.ConnectionError: Connection error
code :-

from breeze_connect import BreezeConnect
from dotenv import load_dotenv
import os
import pandas as pd

load_dotenv()
# intialize keys

api_key = os.getenv("API_KEY")
api_secret = os.getenv("SECRET")
api_session = os.getenv("SESSION")

# Import Libraries

from datetime import datetime
import pandas as pd
from breeze_connect import BreezeConnect

# Setup my API keys
api = BreezeConnect(api_key=api_key)
api.generate_session(api_secret=api_secret, session_token=api_session)

print("session created")

def on_ticks(ticks):
    print(ticks)

# Main Function
if __name__ == "__main__":
    print("Starting Execution \n")

    # Switch on Websockets
    api.ws_connect()
    api.on_ticks = on_ticks
    api.subscribe_feeds(stock_token = "one_click_fno")
@Idirect-Tech Idirect-Tech self-assigned this Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants