1006 connection closed abnormally

I am trying to run this example: martingale (https://alpaca.markets/learn/martingale-day-trading-python/)
and I get connection error after a couple of hours. I ran this via the paper account for a few days and I got the same error every day:

WARNING:root:code = 1006 (connection closed abnormally [internal]), no reason
Traceback (most recent call last):
File “view_trades.py”, line 143, in

File “view_trades.py”, line 138, in start_trading
conn.run([f’alpacadatav1/T.{self.symbol}’, ‘trade_updates’])
File “…\anaconda3\envs\py36\lib\site-packages\alpaca_trade_api\stream2.py”, line 276, in run
File “…\anaconda3\envs\py36\lib\asyncio\base_events.py”, line 484, in run_until_complete
return future.result()

1 Like

I have the exact same issue. Did you solve it? Would love to know how to.


No I stopped using stream and I am just using REST now.

i tried REST but ran into too man api calls. I am going to try to figure it out.