Layer 7 API Gateway: Testing a websocket connection via cURL
search cancel

Layer 7 API Gateway: Testing a websocket connection via cURL

book

Article ID: 142115

calendar_today

Updated On:

Products

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

Issue/Introduction

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

Environment

Release : 9.x

Component : API Gateway

Resolution

cURL can be used locally on the Gateway

 

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


where:

- 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.