Azure APIM WebSocket API Connection Issue

Lakshmi Siva Kumar Viswanadula 65 Reputation points
2025-01-14T16:40:41.59+00:00

I have created a backend using app service (websocket connections is alwayson), I would like to add APIM as a pass thru websocket API. However, I received InvalidWebSocketUpgrade.

Sample backend url from the Dev Tools: wss://sandbox.azurewebsites.net/

APIM WebsocketAPI: apim-sandbox1.azure-api.net_event/?EIO=4&transport=websocket

Below are the request headers:

accept-encoding: gzip, deflate, br, zstd

accept-language: en-US,en;q=0.9

cache-control: no-cache

connection: Upgrade

host: apim-sandbox1.azure-api.net

origin: https://sandbox.azurestaticapps.net

pragma: no-cache

sec-websocket-extensions: permessage-deflate; client_max_window_bits

sec-websocket-key: 16KVjz7mVdkVefVd6KD9yg==

sec-websocket-version: 13

upgrade: websocket

user-agent:

Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1 Edg/130.0.0.0

What am I doing wrong and what should be my base url and inbound policies for the above scenario

Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
2,261 questions
{count} votes

1 answer

Sort by: Most helpful
  1. LeelaRajeshSayana-MSFT 16,946 Reputation points
    2025-01-14T23:59:42.2766667+00:00

    Hi @Lakshmi Siva Kumar Viswanadula Greetings! I was referencing to the following developer blog Import a WebSocket API in API Management and it was mentioned that if the websocket URL endpoint in APIM is wss://demo-apim-oauth.azure-api.net/wsapiwebscoketdemo, then the request URL that client sends cannot contain any additional parameters such as follows wss://demo-apim-oauth.azure-api.net/wsapiwebscoketdemo/{extraParam} 

    Can you please confirm if your request does not contain any additional parameters and matches the correct format?

    Please also refer the document link for current limitations of WebSocket API in APIM.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.