Ratelimit for websocket connection

How can I rate-limit the websocket connections throughput.
In my application, kong does not log the request till the websocket client closes the connection. But i want to limit the max data exchanged and maximum time for which the connection can be open, through Kong.
How can I achieve this.
I am using kong 0.14

1 Like

This is not possible to do.
Kong is not aware of websocket messages that are flowing through an HTTP stream.

1 Like

Is there a work around to get it aware of the websocket request ?
I found some info on it, but cant get it to work.

Websocket

nginx_http_map $http_upgrade $connection_upgrade {
default upgrade;
‘’ close;
}

Proxy Websocket Upgrade request

nginx_proxy_pass http://backend;
nginx_proxy_http_version 1.1;
nginx_proxy_set_header Upgrade $http_upgrade;
nginx_proxy_set_header Connection $connection_upgrade;