Layer 7 API Gateway: Testing a websocket connection via cURL


Article ID: 142115


Updated On:


CA API Gateway API SECURITY CA API Gateway Precision API Monitoring Module for API Gateway (Layer 7) CA API Gateway Enterprise Service Manager (Layer 7) STARTER PACK-7 CA Microgateway


How can we confirm a Websocket connection is successful to the Gateway?


Release : 9.x

Component : API Gateway


cURL can be used locally on the Gateway


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


- The Origin header is optional when using cURL but should match the originating request if used

- The Host header should match the requested host

- 7777 is the port opened for WebSocket communication


Additional Information

If you attempt to access the WebSocket port over HTTP without the required headers you will receive an HTTP 404 error. 

This is to be expected as the Gateway is set to serve a Websocket connection over this port. Without the proper headers, it will attempt to server HTTP/HTTPS traffic.