7

I am trying to implement a healthcheck for WebSocket server with curl.

curl --include --no-buffer \ --header "Connection: Upgrade" \ --header "Upgrade: websocket" \ --header "Sec-WebSocket-Key: SGVsbG8sIHdvcmxkIQ==" \ --header "Sec-WebSocket-Version: 13" \ http://localhost:3000 

I send an HTTP request to do the handcheck, and receive an HTTP 101 as expected :

HTTP/1.1 101 Switching Protocols Upgrade: websocket Connection: Upgrade Sec-WebSocket-Accept: qGEgH3En71di5rrssAZTmtRTyFk= 

My issue is that after receiving that response, curl will just hang.

Is there any way to tell curl to exit after that successful handshake?

1 Answer 1

7

You can use Connection: close instead of Connection: Upgrade in order to specify that the connection should be closed after the completion of the response :

curl --include --no-buffer \ --header "Connection: close" \ --header "Upgrade: websocket" \ --header "Sec-WebSocket-Key: SGVsbG8sIHdvcmxkIQ==" \ --header "Sec-WebSocket-Version: 13" \ http://localhost:3000 
Sign up to request clarification or add additional context in comments.

2 Comments

can I translate this to be programmatically done by node http module? nodejs.org/api/http.html
would this be considered a valid way to do the same request pastebin.com/xhAqpHkH

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.