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

Error: __on_close_callback() takes from 1 to 2 positional arguments but 4 were give #40

Open
alokgpee opened this issue Mar 24, 2022 · 2 comments

Comments

@alokgpee
Copy link

Getting below issue very frequently after some time of running program.

ERROR:websocket:error from callback <bound method AlphaTrade.__on_close_callback of <alphatrade.alphatrade.AlphaTrade object at
0x0000025FC445FF70>>: __on_close_callback() takes from 1 to 2 positional arguments but 4 were given

Generally happens on calling following function:
sas.subscribe(optionType, LiveFeedType.COMPACT)

Trace logs are as follows:
ERROR:websocket:error from callback <bound method AlphaTrade.__on_close_callback of <alphatrade.alphatrade.AlphaTrade object at
0x0000025FC445FF70>>: __on_close_callback() takes from 1 to 2 positional arguments but 4 were given

Traceback (most recent call last):
File "d:\alokguptaxggn\python_sandbox\python_stories\python_stories\01-Development\algoTrade\63AlgoTrade-MIS-4-RSI-56.py", line 238, in
putBuyPrice = getOptionPrice(sas, NIFTY_PUT)
File "d:\alokguptaxggn\python_sandbox\python_stories\python_stories\01-Development\algoTrade\63AlgoTrade-MIS-4-RSI-56.py", line 20, in getOptionPrice
sas.subscribe(optionType, LiveFeedType.COMPACT)
File "C:\Users\alokg\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\alphatrade\alphatrade.py", line 857, in subscribe
return self.__ws_send(data)
File "C:\Users\alokg\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\alphatrade\alphatrade.py", line 460, in __ws_send
self.__websocket.send(*args, **kwargs)
ocal\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Pythonpy", line 203, in send
if not self.sock or self.sock.send(data, opcode) == 0:
File "C:\Users\alokg\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\websocket_core.py", line 283, in send
return self.send_frame(frame File "C:\Users\alokg\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\websocket_core.py", line 311, in send_frame
l = self._send(data)
File "C:\Users\alokg\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\websocket_core.py", line 525, in _send
return send(self.sock, data) File "C:\Users\alokg\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\websocket_socket.py", line 146, in send
raise WebSocketConnectionClosedException("socket is already closed.")
websocket._exceptions.WebSocketConnectionClosedException: socket is already closed.

@algo2t
Copy link
Owner

algo2t commented Apr 1, 2022

Is it possible for your to share the code? using code formatting. I will check it out

@ronaldpaul
Copy link

ronaldpaul commented Aug 23, 2022

Is it possible for your to share the code? using code formatting. I will check it out

Hi @algo2t, I am also receiving this error quite often. It happens sporadically.

2022-08-23 12:52:01,310 - ERROR - algo_test.py:292 - Error in subscribing to main instrument : EOF occurred in violation of protocol (_ssl.c:2384)

This happens when I try to subscribe to Nifty feed. Probably it could be for any instrument and not just for Nifty.

try:
    x = sas.get_instrument_by_symbol('NSE', 'Nifty 50')
    sas.subscribe(x, LiveFeedType.COMPACT)
    subscribed = len(sas._AlphaTrade__subscribers)
    sleep(1)
except Exception as e:
    logging.error('Error in subscribing to main instrument : ' + str(e))

Does it has something to do with insufficient memory (RAM)? or anything else? Kindly help.

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

3 participants