harwee/IQOption-Api

Websocket is getting closed

Closed this issue · 8 comments

When I try to login I got the following error:

    api.login()
  File "C:\Python35\lib\site-packages\iqoption_api\api.py", line 57, in login
    self.get_instruments()
  File "C:\Python35\lib\site-packages\iqoption_api\api.py", line 217, in get_instruments
    self.send_socket_message("sendMessage",{"name":"get-instruments","version":"1.0","body":{"type":ele}})
  File "C:\Python35\lib\site-packages\iqoption_api\api.py", line 134, in send_socket_message
    self.socket.send(json.dumps(data))
  File "C:\Python35\lib\site-packages\websocket\_app.py", line 147, in send
    if not self.sock or self.sock.send(data, opcode) == 0:
  File "C:\Python35\lib\site-packages\websocket\_core.py", line 240, in send
    return self.send_frame(frame)
  File "C:\Python35\lib\site-packages\websocket\_core.py", line 265, in send_frame
    l = self._send(data)
  File "C:\Python35\lib\site-packages\websocket\_core.py", line 430, in _send
    return send(self.sock, data)
  File "C:\Python35\lib\site-packages\websocket\_socket.py", line 114, in send
    raise WebSocketConnectionClosedException("socket is already closed.")
websocket._exceptions.WebSocketConnectionClosedException: socket is already closed.

Please let me know how I can resolve it. I was not getting this issue previously.

Thank you @harwee . I guess you are busy to reply. and might have abandoned the repository. Please my humble request you write a note on your repository that you are not at all responding to anyone here after, so people won't waste time to wait for you to reply. Thank you once again.

@JafferWilson If you are still using trying some other repo, I have rewritten some of the functionality using async if you are interested you can use this branch, https://github.com/harwee/IQOption-Api/tree/async

Thank you for the reference.

@harwee
Your repository is not working:

Python 3.5.0 (v3.5.0:374f501f4567, Sep 13 2015, 02:27:37) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from iqoption_api import IQOption
>>> iqoption = IQOption("email@email.com","pass")
>>> iqoption.start()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'IQOption' object has no attribute 'start'
Python 3.6.7 |Anaconda, Inc.| (default, Oct 23 2018, 19:16:44) 
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from iqoption_api import IQOption
>>> iqoption = IQOption("email","pass")
>>> iqoption.start()
2018-11-29 18:33:48,757 - iqoption-api - INFO - Socket Connection Established
2018-11-29 18:33:48,757 - iqoption-api - INFO - Started monitoring Incoming socket messages
2018-11-29 18:33:48,763 - iqoption-api - INFO - User Balance Id: ********
2018-11-29 18:33:49,966 - iqoption-api - INFO - Init Complete
>>> 

It does work make sure you are using the code from async branch.

and also this doesn't work for python==3.5 it works for python >= 3.6

oh.. what a bummer! I have my complete project written in python 3.5. It is not worth for me to shift on Python 3.6, as I don't know what issues it might create while running the project.
Well, thank you for the information.

Python 3.5 asyncio library is provisional API, it is stable only after 3.6, so I considered rewriting it using stable API, I will add Tornado after adding more features to support versions less than 3.6, maybe then.

Oh.. That will be great.. Thank you.