n1nj4z33 / iqoptionapi

IQ Option API 4.x (Python 2.7) The project is obsolete and is not supported because of problems with access to IQ Options in Russia
120 stars 545 forks source link

WebSocketConnectionClosedException - After using PyInstaller #6

Open joebrassi opened 8 years ago

joebrassi commented 8 years ago

I wrote a simple app to print the balance and server times:

from iqapi.api import IQOptionAPI
from time import sleep

_author_ = 'wombat'

class Solver:
    def demo(self):
        api = IQOptionAPI("iqoption.com", "username", "password")
        api.connect()

        while 0 == 0:
            sleep(1)
            print(api.profile.balance)
            print(str(api.timesync.expiration_datetime))
            print(str(api.timesync.server_datetime))

Solver().demo()

If I compile and execute the code using:

C:\Users\User1\Python-3.5.2\Scripts\python.exe "D:/pythonsamples/Solver.py"

It will work. But, if I execute PyInstaller

$ pyinstaller --onefile --paths="C:\Users\User1\Python-3.5.2\Lib" --paths="C:\Users\User1\Python-3.5.2\Lib\site-packages" Solver.py

to create an executable file of this code, then I get the following error:

Traceback (most recent call last):
  File "Solver.py", line 19, in <module>
  File "Solver.py", line 11, in demo
  File "iqapi\api.py", line 288, in connect
  File "iqapi\ws\chanels\ssid.py", line 18, in __call__
  File "iqapi\ws\chanels\base.py", line 25, in send_websocket_request
  File "iqapi\api.py", line 125, in send_websocket_request
  File "site-packages\websocket\_app.py", line 116, in send
websocket._exceptions.WebSocketConnectionClosedException: Connection is already closed.

Any idea why is this happening?

Niks005 commented 7 years ago

Same issue. I checked, on_error is cafile, capath and cadata cannot be all omitted. Any update?

Niks005 commented 7 years ago

Any update on this issue? Same this is happening with py2xe. After creating exe it doen't work

boskiv commented 7 years ago

Maybe you can use docker for windows to run it from unix container ?

boskiv commented 7 years ago

something like docker run -v .:/code python:3 python /code/Solver.py

Niks005 commented 7 years ago

make websocket folder and copy pythonxx/Lib/site-pakages/websocket/cacert.pem file into it.