400 Bad request when connecting to data stream

I’m trying to open a WebSocket connection to “wss://stream.data.alpaca.markets/v2/iex” but I keep getting a 400 error. For reference, I’m using the StarScream sockets library for Swift. My socket code is able to connect to “ws://echo.websocket.org/” just not the alpaca iex streaming endpoint. Any suggestions?


GET /v2/iex HTTP/1.1
Upgrade: websocket
Origin: wss://stream.data.alpaca.markets
Host: stream.data.alpaca.markets:443
Connection: Upgrade
Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits; server_max_window_bits=15
Sec-WebSocket-Key: ...
Sec-WebSocket-Version: 13
Content-Type: application/json


HTTP/1.1 400 Bad Request
Date: Tue, 03 Aug 2021 18:05:47 GMT
Content-Type: text/plain; charset=utf-8
Content-Length: 70
Connection: keep-alive
Sec-Websocket-Accept: ...
Upgrade: websocket
X-Content-Type-Options: nosniff
Strict-Transport-Security: max-age=15724800; includeSubDomains