'Rate limit API Management by Websocket protocol as key?
Has anyone successfully configured an azure api management policy to rate limit websocket connections using the "protocol" as key for limiting?
The use case is that websocket protocol carries an apikey.
I can't find any info on azure docs on how to dig that value from policy context variable
Solution 1:[1]
I found out that Sec-WebSocket-Protocol http header carries this string, and was able to set it as counter-key with something like
counter-key="@(context.Request.Headers.GetValueOrDefault("Sec-WebSocket-Protocol"))"
in the policy.
If this is a good practice, or can miss some ways of providing the protocol is another question completely.. But it seems to work.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | tonsteri |
