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

1006 error still happening #265

Closed
dandwfdm opened this issue Jul 9, 2020 · 29 comments
Closed

1006 error still happening #265

dandwfdm opened this issue Jul 9, 2020 · 29 comments

Comments

@dandwfdm
Copy link

dandwfdm commented Jul 9, 2020

Got the most recent code which I thought had a solution to this problem, but still getting it. Have had 2 today.

Here is the Traceback. Any help would be appreciated.

WARNING:root:code = 1006 (connection closed abnormally [internal]), no reason
Traceback (most recent call last):
File "C:/Projects/stocks/src/main.py", line 272, in
main()
File "C:/Projects/stocks/src/main.py", line 156, in main
trading.ws_start()
File "C:\Projects\stocks\src\trading.py", line 381, in ws_start
self.conn.run(['AM.SPY', 'trade_updates'])
File "C:\Projects\stocks\src\alpaca_trade_api\stream2.py", line 287, in run
loop.run_until_complete(self.consume())
File "C:\Users\jimpc4\AppData\Local\Programs\Python\Python38\lib\asyncio\base_events.py", line 616, in run_until_complete
return future.result()
asyncio.exceptions.CancelledError

@shlomiku
Copy link
Contributor

Hi,
websocket disconnection may happen.
in the master branch (not yet released to pip) we handle this by reconnecting to the servers.
try installing directly from github and see if that resolves your issue.
you can do this like so: pip install -U git+https://github.com/alpacahq/alpaca-trade-api-python

@dandwfdm
Copy link
Author

dandwfdm commented Jul 10, 2020

Hi,
was using the latest one. Here is the code:

       loop = self.loop
        should_renew = True  # should renew connection if it disconnects
        while should_renew:
            try:
                if loop.is_closed():
                    self.loop = asyncio.new_event_loop()
                    loop = self.loop
                loop.run_until_complete(self.subscribe(initial_channels))
                loop.run_until_complete(self.consume())
            except KeyboardInterrupt:
                logging.info("Exiting on Interrupt")
                should_renew = False
            except Exception as e:
                logging.error(f"error while consuming ws messages: {e}")
                loop.run_until_complete(self.close(should_renew))
                if loop.is_running():
                    loop.close()

@rizzomichaelg
Copy link

I'm having a very similar issue using the same latest push

@shlomiku
Copy link
Contributor

I will need some more information in order to try and reproduce the issue.

  1. a sample code of what you do to execute locally (if possible, or at least something similar)
  2. does it happen every time you execute?
  3. does it continue execution or anything at all after that happens?
  4. do you have to wait for a long time to get this or does it happen immediately?

@rizzomichaelg
Copy link

rizzomichaelg commented Jul 12, 2020

  1. Here is my sample code
class DisconnectedException(Exception):
    pass

class Quit(Exception):
    pass

conn = alpaca_trade_api.StreamConn(
    self.key_id,
    self.secret_key,
    base_url=self.api_endpoint,
    data_stream="polygon"
)

@conn.on(r'^status$')
async def on_status(conn, channel, data):
    print('polygon status update', data)
    if data.status == 'disconnected':
        print('Disconnected. Going to try to reconnect...')
        self.disconnected = True
        await conn.close()
        print('awaited conn close')
        raise DisconnectedException('Disconnected')

async def periodic():
    while True:
        # if not self.api.get_clock().is_open:
        if not self.api.get_clock().is_open or self.api.get_clock().timestamp >= break_time:
            print('done for today')
            raise Quit('Quit')
        if self.disconnected:
            print('raise from periodic')
            raise DisconnectedException('Disconnected')
        await asyncio.sleep(30)

should_continue = True

def exception_handler(loop, context):
    global should_continue
    # first, handle with default handler
    loop.default_exception_handler(context)
    loop.stop()
    print('exception handler')
    print(context)
    if 'exception' in context and context['exception'] == DisconnectedException:
        should_continue = True

print('Now streaming...')
channels = ['trade_updates'] + ['AM.{}'.format(s) for s in self.symbols]

should_sell = False
while should_continue:
    should_continue = False
    try:
        loop = conn.loop
        loop.set_exception_handler(exception_handler)
        self.disconnected = False
        loop.run_until_complete(asyncio.gather(
            conn.subscribe(channels),
            periodic(),
        ))
        loop.close()
    except Quit:
        print('Quit Exception')
        should_sell = True
    except DisconnectedException:
        print('Disconnected')
        should_continue = True
    except ConnectionClosedError as e:
        print('ConnectionClosedError', e)
        should_continue = True
        sleep(5)
    except Exception as e:
        print('Caught exception', e)

And then the log messages I receive are as follows:

polygon status update Entity({   'ev': 'status',
    'message': 'Polygon Disconnected Unexpectedly (code = 1006 (connection '
               'closed abnormally [internal]), no reason)',
    'status': 'disconnected'})
Disconnected. Going to try to reconnect...
raise from periodic
Disconnected
ConnectionClosedError code = 1006 (connection closed abnormally [internal]), no reason
ConnectionClosedError code = 1006 (connection closed abnormally [internal]), no reason
ConnectionClosedError code = 1006 (connection closed abnormally [internal]), no reason
  1. It does happen every time, and seems to happen around 11am
  2. Nothing happens following this exception for repeated ConnectionClosedErrors
  3. See 2. Happens around 11am after having been running for 1.5 hours.

Thanks for the help!

@dandwfdm
Copy link
Author

  1. sample below
  2. it does not happen every time. Once every few days. Sometimes a few times in one day. Happened today 10:12 ET. Attached error log.
  3. execution is aborted
  4. happens at random times after starting, but generally it takes a while.

Last error:
{'Date_Time': '2020-07-14 10:12:00-04:00', 'Open': 312.73, 'High': 312.93, 'Low': 312.45, 'Close': 312.55, 'Volume': 6102, 'Time': '10:12:00', 'Date': '2020-07-14'}
In Position: False trade type: None Buy: True Sell: True
WARNING:root:code = 1006 (connection closed abnormally [internal]), no reason
Traceback (most recent call last):
File "C:/Projects/stocks/src/main.py", line 272, in
main()
File "C:/Projects/stocks/src/main.py", line 156, in main
trading.ws_start()
File "C:\Projects\stocks\src\trading.py", line 381, in ws_start
self.conn.run(['AM.SPY', 'trade_updates'])
File "C:\Projects\stocks\src\alpaca_trade_api\stream2.py", line 287, in run
loop.run_until_complete(self.consume())
File "C:\Users\jimpc4\AppData\Local\Programs\Python\Python38\lib\asyncio\base_events.py", line 616, in run_until_complete
return future.result()
asyncio.exceptions.CancelledError

Sample code:

*** In main call setup, then call ws_start, then loop forever doing a sleep(10)

def setup(self):
    """
    Setup the trading system.
    Create API connections with the live trading environment.
    Check for existing positions, terminating if there is more than one
    Get the system in the proper state for any existing positions
    Wait until the market is open before finishing the method.
    """
    with open("alpaca_config.json") as config_file:
        config = json.load(config_file)

    try:
        api_key = config['api_key']
        api_secret = config['secret_key']
        base_url = config['base_url']
        self.conn = StreamConn(api_key, api_secret, base_url)
        self.api = REST(api_key, api_secret, base_url)
        # TODO: Handle other errors that can occur when forming connection
    except KeyError:
        print("Error - missing api_key, api_secret, or base_url. \n Terminating - go check alpaca_config.")
        exit()
async def on_minute(self, conn, channel, bar):
    """
    Called each minute when receiving data over websockets from Alpaca.

    :param conn:
    :param channel:
    :param bar: stock data for the last minute
    :return:
    """
   pass    # dummy to show routine that is called

def ws_start(self):
    # This is another way to setup wrappers for websocket callbacks, handy if conn is not global.
    self.on_minute = self.conn.on(r'AM.SPY')(self.on_minute)
    self.on_trade_updates = self.conn.on(r'trade_updates')(self.on_trade_updates)
    print("Minutes to close: {:.2f}".format(self.time_to_market_close()))
    try:
        self.conn.run(['AM.SPY', 'trade_updates'])
    except Exception as e:
        print("conn.run exception: ", e)

@shlomiku
Copy link
Contributor

hi @rizzomichaelg tried to work with your code example..

  1. it's a part of your example so it doesn't work.
  2. I fixed the errors to make it execute, but even after that.. it does nothing
    so there's nothing I could debug with this.
    if you could provide a better example code I will run it

@dandwfdm
Copy link
Author

dandwfdm commented Jul 15, 2020 via email

@shlomiku
Copy link
Contributor

@dandwfdm I was referring to rizzomichaelg's code
your code, was not complete as well but I fixed it locally and running it now, hopefully I will encounter the issue you refer too
generally, to to paste code nicely use the backtick (`) like this:

image

and you will get a result like this:

    async def on_minute(self, conn, channel, bar):
        print(bar)    # dummy to show routine that is called

@dandwfdm
Copy link
Author

The following is a version of my code that should run. I ran it earlier and it failed after 6 minutes. Here is the output:

C:\Projects\test\venv\Scripts\python.exe C:/Projects/test/main.py
{'Date_Time': '2020-07-15 12:26:00-04:00', 'Open': 320.28, 'High': 320.45, 'Low': 320.17, 'Close': 320.41, 'Volume': 3431, 'Time': '12:26:00', 'Date': '2020-07-15'}
{'Date_Time': '2020-07-15 12:27:00-04:00', 'Open': 320.44, 'High': 320.48, 'Low': 320.38, 'Close': 320.46, 'Volume': 1802, 'Time': '12:27:00', 'Date': '2020-07-15'}
{'Date_Time': '2020-07-15 12:29:00-04:00', 'Open': 320.635, 'High': 320.72, 'Low': 320.635, 'Close': 320.65, 'Volume': 304189, 'Time': '12:29:00', 'Date': '2020-07-15'}
{'Date_Time': '2020-07-15 12:30:00-04:00', 'Open': 320.62, 'High': 320.69, 'Low': 320.51, 'Close': 320.685, 'Volume': 7239, 'Time': '12:30:00', 'Date': '2020-07-15'}
{'Date_Time': '2020-07-15 12:31:00-04:00', 'Open': 320.67, 'High': 320.67, 'Low': 320.46, 'Close': 320.57, 'Volume': 9745, 'Time': '12:31:00', 'Date': '2020-07-15'}
{'Date_Time': '2020-07-15 12:32:00-04:00', 'Open': 320.575, 'High': 320.58, 'Low': 320.28, 'Close': 320.375, 'Volume': 8163, 'Time': '12:32:00', 'Date': '2020-07-15'}
WARNING:root:code = 1006 (connection closed abnormally [internal]), no reason
Traceback (most recent call last):
File "C:/Projects/test/main.py", line 19, in
main()
File "C:/Projects/test/main.py", line 14, in main
trading.ws_start()
File "C:\Projects\test\trading.py", line 92, in ws_start
try:
File "C:\Projects\test\alpaca_trade_api\stream2.py", line 287, in run
loop.run_until_complete(self.consume())
File "C:\Users\jimpc4\AppData\Local\Programs\Python\Python38-32\lib\asyncio\base_events.py", line 616, in run_until_complete
return future.result()
asyncio.exceptions.CancelledError

Process finished with exit code 1

**** the code ***

*** main.py:

import time
from trading import Trading

def main():
# Initialization
backtest_strategy = []
needed_indicators = []

trading = Trading(needed_indicators, backtest_strategy)
trading.setup()
# Start live trading
trading.ws_start()
time.sleep(10)

if name == "main":
main()

**** trading.py

import json
import datetime
from alpaca_trade_api import StreamConn, REST

class Trading:
def init(self, needed_indicators, backtest_strategy):
self.needed_indicators = needed_indicators
self.backtest_strategy = backtest_strategy
self.order_msg = []
self.filled_market_time = None
self.conn = None
self.api = None

def setup(self):
    """
    Setup the trading system.
    Create API connections with the live trading environment.
    Check for existing positions, terminating if there is more than one
    Get the system in the proper state for any existing positions
    Wait until the market is open before finishing the method.
    """
    with open("alpaca_config.json") as config_file:
        config = json.load(config_file)

    try:
        api_key = config['api_key']
        api_secret = config['secret_key']
        base_url = config['base_url']
        self.conn = StreamConn(api_key, api_secret, base_url)
        self.api = REST(api_key, api_secret, base_url)
        # TODO: Handle other errors that can occur when forming connection
    except KeyError:
        print("Error - missing api_key, api_secret, or base_url. \n Terminating - go check alpaca_config.")
        exit()
    print('Setup complete')


async def on_minute(self, conn, channel, bar):
    """
    Called each minute when receiving data over websockets from Alpaca.

    :param conn:
    :param channel:
    :param bar: stock data for the last minute
    :return:
    """
    dts = str(bar.start).format("%Y-%m-%d %H:%M:%S")
    date = str(bar.start.date()).format("%Y%m%d")
    str_time = str(bar.start.time()).format("%H:%M:%S")

    minute_data = {'Date_Time': dts, 'Open': bar.open, 'High': bar.high, 'Low': bar.low, 'Close': bar.close,
                   'Volume': bar.volume, 'Time': str_time, 'Date': date}
    print(minute_data)


async def on_trade_updates(self, conn, channel, trade_status):
    """
    Called when we receive web socket trade updates.

    :param conn:
    :param channel:
    :param trade_status:
    :return:
    """
    self.filled_market_time = trade_status.order['filled_at']

    if self.filled_market_time is not None:
        self.filled_market_time = datetime.datetime.strptime(trade_status.order['filled_at'],
                                                             '%Y-%m-%dT%H:%M:%S.%fZ')
        self.filled_market_time = self.filled_market_time - datetime.timedelta(hours=4)

    # Fill would result from a buy/sell to open position, close a position, or a stop
    if 'fill' in trade_status.event:
        print(trade_status.event, self.filled_market_time, trade_status.order['symbol'],
              trade_status.order['side'], trade_status.order['filled_qty'], trade_status.order['filled_avg_price'],
              trade_status.order['type'], trade_status.order['filled_at'], trade_status.order['updated_at'])

    # this would result from the cancel of a stop when we are going to buy or sell a position
    elif 'canceled' in trade_status.event:
        # print("canceled received")
        pass
    else:
        # print("Event: {} that we are not interested in for now & no code was run".format(trade_status.event))
        pass

def ws_start(self):
    # This is another way to setup wrappers for websocket callbacks, handy if conn is not global.
    self.on_minute = self.conn.on(r'AM.SPY')(self.on_minute)
    self.on_trade_updates = self.conn.on(r'trade_updates')(self.on_trade_updates)
    try:
        self.conn.run(['AM.SPY', 'trade_updates'])
    except Exception as e:
        print("conn.run exception: ", e)

@rizzomichaelg
Copy link

@dandwfdm Apologies, here is my complete example.

from datetime import datetime
from pytz import timezone
from websockets.exceptions import ConnectionClosedError

from time import sleep
import asyncio

import alpaca_trade_api

eastern = timezone('US/Eastern')

ALPACA_API_KEY = ''
ALPACA_SECRET_KEY = ''
ALPACA_API_ENDPOINT = 'https://paper-api.alpaca.markets'

class DisconnectedException(Exception):
    pass

class Quit(Exception):
    pass

class Trader(object):
    def __init__(self, symbols):
        self.key_id = ALPACA_API_KEY
        self.secret_key = ALPACA_SECRET_KEY
        self.api_endpoint = ALPACA_API_ENDPOINT
        self.api = alpaca_trade_api.REST(
            self.key_id,
            self.secret_key,
            base_url=self.api_endpoint
        )
        self.disconnected = False
        self.symbols = symbols

    def start_trading(self):
        conn = alpaca_trade_api.StreamConn(
            self.key_id,
            self.secret_key,
            base_url=self.api_endpoint,
            data_stream="polygon"
        )

        now = datetime.now()
        today = now.strftime('%Y-%m-%d')
        break_time = datetime.strptime(f'{today} 16:00:00', '%Y-%m-%d %H:%M:%S')
        break_time = eastern.localize(break_time)

        @conn.on(r'^status$')
        async def on_status(conn, channel, data):
            print('polygon status update', data)
            if data.status == 'disconnected':
                print('Disconnected. Going to try to reconnect...')
                self.disconnected = True
                await conn.close()
                print('awaited conn close')
                raise DisconnectedException('Disconnected')

        @conn.on(r'^AM$', self.symbols)
        async def handle_agg(conn, channel, data):
            print(data)

        async def periodic():
            while True:
                # if not self.api.get_clock().is_open:
                if not self.api.get_clock().is_open or self.api.get_clock().timestamp >= break_time:
                    print('done for today')
                    raise Quit('Quit')
                if self.disconnected:
                    print('raise from periodic')
                    raise DisconnectedException('Disconnected')
                await asyncio.sleep(30)

        should_continue = True

        def exception_handler(loop, context):
            global should_continue
            loop.default_exception_handler(context)
            loop.stop()
            print('exception handler')
            print(context)
            if 'exception' in context and context['exception'] == DisconnectedException:
                should_continue = True

        print('Now streaming...')
        channels = ['trade_updates'] + ['AM.{}'.format(s) for s in self.symbols]

        while should_continue:
            should_continue = False
            try:
                loop = conn.loop
                loop.set_exception_handler(exception_handler)
                self.disconnected = False
                loop.run_until_complete(asyncio.gather(
                    conn.subscribe(channels),
                    periodic(),
                ))
                loop.close()
            except Quit:
                print('Quit Exception')
            except DisconnectedException:
                print('Disconnected')
                try:
                    pass
                except Exception as e:
                    print('second try just in case', e)
                should_continue = True
            except ConnectionClosedError as e:
                print('ConnectionClosedError', e)
                should_continue = True
                sleep(5)
            except Exception as e:
                print('Caught exception', e)

def main():
    symbols = ['AAPL', 'SBUX']

    trader = Trader(symbols)
    trader.start_trading()


if __name__ == '__main__':
    main()

@shlomiku
Copy link
Contributor

@dandwfdm I ran your sample code for over 3 hours yesterday. there was no issue I encountered.
I will try to execute @rizzomichaelg sample code today, maybe I will find something new

@dandwfdm
Copy link
Author

Ran for 4 1/2 hours today before gettting the error.

@dandwfdm
Copy link
Author

Error after 30 min. today, but as I said, it could run a day or 2 before getting one.

@dandwfdm
Copy link
Author

Failed again after 5 min. after restart

@dandwfdm
Copy link
Author

Ok for 3 1/2 hours till stopped

@rizzomichaelg
Copy link

Still experiencing this issue daily. Any updates?

@dandwfdm
Copy link
Author

dandwfdm commented Aug 3, 2020 via email

@shlomiku
Copy link
Contributor

shlomiku commented Aug 3, 2020

is it still the same sample code?
are you using the most recent code base?
try installing directly from github: pip install git+https://github.com/alpacahq/alpaca-trade-api-python

@dandwfdm
Copy link
Author

dandwfdm commented Aug 3, 2020 via email

@cullenbass
Copy link

I'm still seeing this error popping up occasionally when subscribed to the AM stream, though the library is reconnecting fairly quickly. It looks like there's something going on with PONG responses from the websocket server. Here's some logs I captured:

DEBUG:websockets.protocol:client ! failing OPEN WebSocket connection with code 1011
DEBUG:websockets.protocol:client - state = CLOSING
DEBUG:websockets.protocol:client > Frame(fin=True, opcode=8, data=b'\x03\xf3', rsv1=False, rsv2=False, rsv3=False)
DEBUG:websockets.protocol:client ! timed out waiting for TCP close
DEBUG:websockets.protocol:client x closing TCP connection
DEBUG:websockets.protocol:client ! timed out waiting for TCP close
DEBUG:websockets.protocol:client x aborting TCP connection
DEBUG:websockets.protocol:client - event = connection_lost(None)
DEBUG:websockets.protocol:client - state = CLOSED
DEBUG:websockets.protocol:client x code = 1006, reason = [no reason]
DEBUG:websockets.protocol:client - aborted pending ping: fed70386
WARNING:root:code = 1006 (connection closed abnormally [internal]), no reason
ERROR:root:error while consuming ws messages: consume cancelled
DEBUG:websockets.protocol:client - state = CONNECTING
DEBUG:websockets.protocol:client - event = connection_made(<asyncio.sslproto._SSLProtocolTransport object at 0x7f9529c400>)```

@shlomiku
Copy link
Contributor

Hi, this sounds like normal behavior. especially from the SDK side.
this package is responsible for the client side, not the server side

@JSTHoffman
Copy link

I'm running into a similar issue where the websocket connection is lost and never reconnected. It happens at varying intervals, anywhere from minutes to hours. I'm running the StreamConn in a thread as the documentation suggests.

I'm also starting the stream by scheduling a call to subscribe() with the thread's event loop and then calling event_loop.run_forever(). This is because I need to dynamically subscribe and unsubscribe from channels which doesn't seem to work when using StreamConn.run() (more info here). I'm guessing this is the issue since the reconnection logic looks like it was added to the run() method but wanted to confirm. If that's the case I'll open a new issue related to subscribing and unsubscribing after calling run().

I saved the test script and logs as gists to avoid cluttering this issue with more code.

Environment details:
OS: MacOS 10.15.5
Python version: 3.7.7
SDK version: 0.50.1

Thanks for any help!

@shlomiku
Copy link
Contributor

Hi,
first, there's an example code that demonstrates the usage of the data streams (similar to what you did, but I would suggest working with that as a base): https://github.com/alpacahq/alpaca-trade-api-python/blob/master/examples/websocket_example.py

second, the stream data is not streamed outside market hours (it differs between polygon and the alpaca data stream a bit)
so that could also be something that you experience

third point, this is a bit tricky, asyncio thing - based on my experience, the thread that opens a websocket is the only thread that could send messages to that websocket connection (it relies on the eventloop being the same)
you could take a look on what I did in this project to be able to change the subscribed equities: https://github.com/shlomikushchi/alpaca-proxy-agent

in this project I have 1 ws connection to the api servers, and other websockets that use this one connection to get multiple data streams for different strategies.
I faced similar issues and that's how I overcame them

@nelfata
Copy link

nelfata commented Oct 17, 2020

I have a similar approach like the one mentioned by @JSTHoffman and I did try the proxy functionality but I still have this disconnect error of 1006. Although the frequency of the disconnects have dropped substantially. Have anyone done extensive tests on this?
I am quite sure I am using the websocket from only one asyncio event loop.

@aprsa
Copy link

aprsa commented Dec 2, 2020

Adding my voice to the choir that the latest version of the api (0.51) still does not connect for me, on two separate computers; the older version (0.46) does reconnect correctly. I've not had a chance to look at the source yet, but thought I'd mention it here. Here's the traceback that happens at least daily.

Yesterday:

WARNING: code = 1006 (connection closed abnormally [internal]), no reason
Traceback (most recent call last):
  File "./broker.py", line 1125, in <module>
    conn.run(['trade_updates'])
  File "/usr/local/lib/python3.8/dist-packages/alpaca_trade_api/stream2.py", line 298, in run
    loop.run_until_complete(self.consume())
  File "/usr/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
asyncio.exceptions.CancelledError

Today:

ERROR: Error in data transfer
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/websockets/protocol.py", line 827, in transfer_data
    message = await self.read_message()
  File "/usr/local/lib/python3.8/dist-packages/websockets/protocol.py", line 895, in read_message
    frame = await self.read_data_frame(max_size=self.max_size)
  File "/usr/local/lib/python3.8/dist-packages/websockets/protocol.py", line 971, in read_data_frame
    frame = await self.read_frame(max_size)
  File "/usr/local/lib/python3.8/dist-packages/websockets/protocol.py", line 1047, in read_frame
    frame = await Frame.read(
  File "/usr/local/lib/python3.8/dist-packages/websockets/framing.py", line 133, in read
    data = await reader(length)
  File "/usr/lib/python3.8/asyncio/streams.py", line 731, in readexactly
    self._maybe_resume_transport()
  File "/usr/lib/python3.8/asyncio/streams.py", line 461, in _maybe_resume_transport
    self._transport.resume_reading()
  File "/usr/lib/python3.8/asyncio/sslproto.py", line 344, in resume_reading
    self._ssl_protocol._transport.resume_reading()
AttributeError: 'NoneType' object has no attribute 'resume_reading'
WARNING: code = 1006 (connection closed abnormally [internal]), no reason
Traceback (most recent call last):
  File "./broker.py", line 1125, in <module>
    conn.run(['trade_updates'])
  File "/usr/local/lib/python3.8/dist-packages/alpaca_trade_api/stream2.py", line 298, in run
    loop.run_until_complete(self.consume())
  File "/usr/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
asyncio.exceptions.CancelledError

@guppykang
Copy link

Error is persisting for me as well

@petric3
Copy link

petric3 commented Feb 24, 2022

Still getting the 1006 error with v1.5.0 and no news streamed.
data websocket error, restarting connection: code = 1006 (connection closed abnormally [internal]), no reason

Also, have tested it in golang afterwards and streamed news working fine..

@drew887
Copy link
Contributor

drew887 commented Apr 29, 2022

Hey closing this one out due to inactivity.

Also please see #588 for a more recent issue on this happening. With recent changes to both the SDK and the API itself we believe this issue should be mostly mitigated

@drew887 drew887 closed this as completed Apr 29, 2022
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

10 participants