erdewit / ib_insync

Python sync/async framework for Interactive Brokers API
BSD 2-Clause "Simplified" License
2.81k stars 755 forks source link

Can't seem to connect #139

Closed Harri94 closed 5 years ago

Harri94 commented 5 years ago

I'm trying to connect but getting the below code:

In [16]: ib.connect('127.0.0.1', 7497, clientId=1)                              
API connection failed: TimeoutError()
---------------------------------------------------------------------------
CancelledError                            Traceback (most recent call last)
<ipython-input-16-a066b40ca400> in <module>
----> 1 ib.connect('127.0.0.1', 7497, clientId=1)

~/anaconda3/envs/py3/lib/python3.7/site-packages/ib_insync/ib.py in connect(self, host, port, clientId, timeout)
    227                 is raised. Set to 0 to disable timeout.
    228         """
--> 229         return self._run(self.connectAsync(host, port, clientId, timeout))
    230 
    231     def disconnect(self):

~/anaconda3/envs/py3/lib/python3.7/site-packages/ib_insync/ib.py in _run(self, *awaitables)
    261 
    262     def _run(self, *awaitables: List[Awaitable]):
--> 263         return util.run(*awaitables, timeout=self.RequestTimeout)
    264 
    265     def waitOnUpdate(self, timeout: float = 0) -> bool:

~/anaconda3/envs/py3/lib/python3.7/site-packages/ib_insync/util.py in run(timeout, *awaitables)
    243         if timeout:
    244             future = asyncio.wait_for(future, timeout)
--> 245         result = loop.run_until_complete(future)
    246     return result
    247 

~/anaconda3/envs/py3/lib/python3.7/asyncio/base_events.py in run_until_complete(self, future)
    582             raise RuntimeError('Event loop stopped before Future completed.')
    583 
--> 584         return future.result()
    585 
    586     def stop(self):

CancelledError: 

I've tried ib.disconnect() and ib.isConnected returns False but I just can't reconnect. Has anyone else had this issue?

erdewit commented 5 years ago

It means there's no API socket listening.