Alpaca Streaming Bars Errors

Just wondering if other people are seeing this or if it’s just me:

(keepalive_ping) client ! timed out waiting for pong
(fail_connection) client ! failing OPEN WebSocket connection with code 1011

I’m running the Alpaca API in Python and seeing this regularly.

1 Like

(_run_forever) websocket error, restarting connection: code = 1006 (connection closed abnormally [internal]), no reason
(init) client - state = CONNECTING
(connection_made) client - event = connection_made(<asyncio.sslproto._SSLProtocolTransport object at 0x000001D0B3EFAE80>)
(write_http_request) client > GET /v2/sip HTTP/1.1
(write_http_request) client > Headers([(‘Host’, ‘stream.data.alpaca.markets’), (‘Upgrade’, ‘websocket’), (‘Connection’, ‘Upgrade’), (‘Sec-WebSocket-Key’, ‘’), (‘Sec-WebSocket-Version’, ‘13’), (‘Sec-WebSocket-Extensions’, ‘permessage-deflate; client_max_window_bits’), (‘Content-Type’, ‘application/msgpack’), (‘User-Agent’, ‘Python/3.8 websockets/8.1’)])
(data_received) client - event = data_received(<276 bytes>)
(data_received) client - event = data_received(<30 bytes>)
(read_http_response) client < HTTP/1.1 101 Switching Protocols
(read_http_response) client < Headers([(‘Date’, ‘Fri, 12 Mar 2021 15:12:13 GMT’), (‘Connection’, ‘upgrade’), (‘Sec-Websocket-Accept’, ‘’), (‘Sec-Websocket-Extensions’, ‘permessage-deflate’), (‘Upgrade’, ‘websocket’), (‘Strict-Transport-Security’, ‘max-age=15724800; includeSubDomains’)])
(connection_open) client - state = OPEN
(read_frame) client < Frame(fin=False, opcode=2, data=b’\x91\x82\xa1T\xa7success\xa3msg\xa9connected’, rsv1=False, rsv2=False, rsv3=False)
(read_frame) client < Frame(fin=True, opcode=0, data=b’’, rsv1=False, rsv2=False, rsv3=False)
(write_frame) client > Frame(fin=True, opcode=2, data=b’\x83\xa6action\xa4auth\xa3key<omitted>\xa6secret<omitted>’, rsv1=False, rsv2=False, rsv3=False)
(data_received) client - event = data_received(<54 bytes>)
(read_frame) client < Frame(fin=False, opcode=2, data=b’\x91\x83\xa1T\xa5error\xa4code\xce\x00\x00\x01\x96\xa3msg\xb9connection limit exceeded’, rsv1=False, rsv2=False, rsv3=False)
(read_frame) client < Frame(fin=True, opcode=0, data=b’’, rsv1=False, rsv2=False, rsv3=False)
(write_close_frame) client - state = CLOSING
(write_frame) client > Frame(fin=True, opcode=8, data=b’\x03\xe8’, rsv1=False, rsv2=False, rsv3=False)
(data_received) client - event = data_received(<4 bytes>)
(read_frame) client < Frame(fin=True, opcode=8, data=b’\x03\xe8’, rsv1=False, rsv2=False, rsv3=False)
(connection_lost) client - event = connection_lost(None)
(connection_lost) client - state = CLOSED
(connection_lost) client x code = 1000, reason = [no reason]
(close_connection) client x closing TCP connection
(streamer) Error: connection limit exceeded

1 Like

I got a similar error. I’m running a python script, and I got this error while streaming sip data:
websocket error, restarting connection: code= 1006 (connection closed abnormally[internal]), no reason

1 Like

The code looks different with the new api, I’m using:

def run_stream(stream):
    try:
        stream.run()
    except Exception as e:
        print(f'Exception from websocket connection: {e}')
    finally:
        print("Trying to re-establish connection")
        sleep(3)
        run_stream(stream)

Yeah, I guess my question would be more along the line of why does it continually happen rather than what workarounds to do when it happens. While I’m glad to hear it’s not just me, these kinds of errors seem to indicate stability/reliability issues with the service…

1 Like

I Agree. I get 1006 randomly, so now I am trying to implement a catch reconnect, resubscribe.

1 Like