3

Had a question about how to use CURL to initiate a WebSocket connection to a server to read from it.

Been referring to the below:

curl --include \
     --no-buffer \
     --header "Connection: Upgrade" \
     --header "Upgrade: websocket" \
     --header "Host: example.com:80" \
     --header "Origin: http://example.com:80" \
     --header "Sec-WebSocket-Key: SGVsbG8sIHdvcmxkIQ==" \
     --header "Sec-WebSocket-Version: 13" \
     http://example.com:80/

From the below links

How to read websocket response in linux shell

Test a WebSocket using curl.

  • Question

We have a secure WebSocket connection. How would I go about doing the same above for a [wss] secure WebSocket connection, and add certs to it as well? I have not been able to find the "Sec-WebSocket-Key:", where would this usually be at?

P.S Also wondering if the secure WebSocket connection can be made using Postman?

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
Sriraag
  • 53
  • 2
  • 8
  • 2
    Regarding `Sec-WebSocket-Key`, the WebSocket client chooses its own value for that header. The value is used by the server to calculate a response that is sent back to the client in the `Sec-WebSocket-Accept` header. The client can then validate the server's response. Read the [WebSocket spec](https://datatracker.ietf.org/doc/html/rfc6455). – Remy Lebeau Jun 25 '21 at 00:45

0 Answers0