I am creating a plugin for kong and I am in doubt if it could be done.
What I need to do with this plugin is basically destroy, close, the connection after a given time (each connection has a different expiration time). I’m using a websocket.
Could this be done?
You can give body filter a try. Although if there is no data between the server and client it won’t be invoked anyway.
Likely this is not achievable with Lua.
Update: I looked into the ngx_http_upstream_process_upgraded function, it seems that WebSocket proxying bypasses the body filter completely (which kinda makes sense). So body filter won’t work either.
You could possibly terminate websocket in plugin and make the plugin make another websocket to upstream. I have always wanted to make that kind of plugin. E.g. websocket in, rest to upstream, which makes all the rest apis websocket apis too. But I have not went further with the idea. Or perhaps otherway around, rest in, and websockets to upstream.