Websocket client with headers
I'm trying to create a websocket client that has an authorization header. It seems that a lot of the functionality of websockets has been moved out of the standard library, and I don't see much in the core. Any advice on how to proceed?
For reference, I'm trying to do the following in Deno, rather than by using websocat:
https://trading-api.readme.io/reference/introduction#connecting
Kalshi Developer Suite
Market Data Feed
Protocol overview Our websockets api is only served over an encrypted connection. There is a single endpoint to establish WS connections: wss://trading-api.kalshi.com/trade-api/ws/v2. We provide multiple channels of information over a single connection. So after establishing a WS connection, the cli...
21 Replies
they are using this header in unintended way π
I believe it would look like this xD
because this header is used to specify "inner?" protocol
Interesting, when I try that I get an "Invalid protocol value" runtime error
as I've said - they made it working like this server-side
I see
they read and parse that "as protocol"... tbh it is genious if it is not somewhat insecure xD
haha
Tools like websocat an uwsc have a headers flag, are they passing it as a protocol?
no, w8, looks like I am uneducated, take a look here:
Medium
WebSockets (client & server) in Deno
Learn about WebSockets in Deno by writing a simple chat app
they talk about authing your ws connection here
hope it helps ^^
I'll take a look - thanks for the help!
^^
From the article:
If the client doesnβt support sending authorization headers, the secure token can be sent in URL:How do you think you would send
Authorization: Bearer ${token}
in the URL?
I think this is probably done on the server, too. So I don't think this is a general work around it, but rather a way around it if you control the client and server
I'm thinking that it's probably that I need to make an HTTP request to the server and then upgrade the connection. I'm not exactly sure how to do that yet...TOKEN-1 is your token
I think I tried that, but let me make sure
Yeah, it doesn't seem to work. I'm getting an authorization error trying to open the websocket (I'm able to connect with websocat with the same token)
If you can open your source or invite me - I would be interested in what are you making π
I mean
at this point most likely you know abot this topic more than me
when I had to do this stuff I had some flow like this...
I had "please give me session link" rest route, it gave you presigned url for websocket
and I was assuming that the client that knows this random route is the same who asked on the rest route