2

Hi all! I am trying to implement websocket in js and want to send authorization jwt to server. but couldn't because it only support protocols. Any other websocket client library jn js that could help to achieve it?

Comments
  • 2
    "because it only supports protocols" doesn't really make any sense. Please rephrase.
  • 2
    No idea what you're talking about but if you're using node I recommend looking at socket.io
  • 0
    i am using websockets from client side, server needs auth token. but its not possible, because you cannot send header as parameters in websocket().
  • 0
    @necromancer You're still bring super vague and not providing required details
  • 0
    @alexbrooklyn what is missing?
  • 1
    @Ranchu No i am not using nodejs. server has been already developed using django. I am using javascript.
  • 2
    Couldn't you do the authorization in a message instead of in header?
  • 3
    Usually you send an HTTP(S)-request with the Authorization-Header to an API-endpoint. The API-server then upgrades your HTTP(S)-connection to a websocket-connection. From that point on it is neither necessary nor possible to send further HTTP-headers (or for the websocket server to read them), since it isn't an HTTP-connection anymore, it is a socket now.
  • 0
    How would you upgrade the Connection?
  • 1
    @blackfaded Buy a premium version?
  • 0
    @blackfaded https://developer.mozilla.org/en-US...
    I have only done that in Go so far, you have an connection upgrader provided by the websocket framework there.
Add Comment