Kotak-Neo / kotak-neo-api

112 stars 103 forks source link

[New user] error- connection was closed uncleanly -NOW RESOLVED #178

Open shitizbansal247 opened 3 months ago

shitizbansal247 commented 3 months ago

i am running it for the first time. when i run the following code on pycharm, it shows error: Connection error: 1006 - connection was closed uncleanly (WebSocket connection upgrade failed (400 - BadRequest))

my code is

from neo_api_client import NeoAPI def on_message(message): print("hi") def on_error(error_message): print("haa")

def on_close(message): print("kya")

def on_open(message): print("hai")

x = "xxxx" client = NeoAPI(consumer_key="xxxx", consumer_secret="xxxx", environment='prod', access_token=x, neo_fin_key=None)

thats it. here i have hidden my access token, consumer key and consumer secret. Please help.

crypt0inf0 commented 3 months ago

Try,

from neo_api_client import NeoAPI
def on_message(message):
    print(message)

def on_error(error_message):
    print(error_message)

def on_close(message):
    print(message)

def on_open(message):
    print(message)

client = NeoAPI(
    consumer_key="",
    consumer_secret="",
    environment="prod",
    access_token=None,
    neo_fin_key=None,
)
client.login(mobilenumber="+91", mpin="")
otp = input("enter otp: ")
client.session_2fa(OTP=otp)

# Get Portfolio Holdings
client.holdings()
shitizbansal247 commented 3 months ago

issue has been resolved. thanks for your cooperation