# Connecting to the websocket - 1006 error

**URL:** <https://forum.alpaca.markets/t/connecting-to-the-websocket-1006-error/590>\
**Category:** Alpaca Integration Applications\
**Created:** [December 29, 2019, 9:29pm UTC](https://forum.alpaca.markets/t/connecting-to-the-websocket-1006-error/590 "2019-12-29T21:29:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![chriscbs](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/chriscbs/32/330_2.png) [@chriscbs](https://forum.alpaca.markets/u/chriscbs)\
**Post date:** [December 29, 2019, 9:29pm UTC](https://forum.alpaca.markets/t/connecting-to-the-websocket-1006-error/590/1 "2019-12-29T21:29:28Z")

</div>

I’m trying to connect to the websocket to get access to order updates. I’m using the faye-websocket-ruby gem and the code seems pretty straightforward. When I run the code I immediately get a “close, 1006” message.

I’ve tried sending the authentication JSON after the connection opens, but I don’t think it’s even getting past _ws = Faye::WebSocket::Client.new(‘[https://paper-api.alpaca.markets/stream](https://paper-api.alpaca.markets/stream)’)_

Do I have the correct endpoint? Anyone else struggling with the same thing?

```
  def listen
        EM.run {
          ws = Faye::WebSocket::Client.new('https://paper-api.alpaca.markets/stream')
      
      ws.on :open do |event|
        p [:open]
      end

      ws.on :message do |event|
        p [:message, event.data]
      end

      ws.on :close do |event|
        p [:close, event.code, event.reason]
        ws = nil
      end
    }
  end
```

---

<div class="post-metadata">

**Author:** ![chriscbs](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/chriscbs/32/330_2.png) [@chriscbs](https://forum.alpaca.markets/u/chriscbs)\
**Post date:** [December 30, 2019, 3:39pm UTC](https://forum.alpaca.markets/t/connecting-to-the-websocket-1006-error/590/2 "2019-12-30T15:39:51Z")

</div>

Disregard - I figured it out.

Had the wrong endpoint, and for anyone else using Ruby, you need to use the MessagePack gem to unpack the messages received from the stream.

---

<div class="post-metadata">

**Author:** ![Felipe\_Cunha](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/felipe_cunha/32/631_2.png) [@Felipe\_Cunha](https://forum.alpaca.markets/u/Felipe_Cunha)\
**Post date:** [April 15, 2020, 1:02pm UTC](https://forum.alpaca.markets/t/connecting-to-the-websocket-1006-error/590/3 "2020-04-15T13:02:19Z")

</div>

Hi Chris!

I’m impressed that this is the only post regarding this problem.

I’m trying to deploy my bot on the cloud (PA and Heroku), but I’m running into the same problem. After running for a couple of hours the web socket disconnects.

Can you share more about your setup?

Thanks
