Closed StarlightIbuki closed 1 year ago
It looks like a hack and relies on an undocumented implementation detail of resty.http
. Anyone could suggest a better idea?
Also, I am not sure if this is permitted by the RFC.
I do not believe this is a good idea. As WebSocket is bi-directional and it is expected to receive message from the other end at any moment, this won't work well with typical keepalive behavior (Nginx will close the keepalive connection immediately if any data is received on a keepalived connection). Plus, using keep-alive is like using WebSocket like a regular HTTP request, why not just use HTTP instead?
Plus, using keep-alive is like using WebSocket like a regular HTTP request, why not just use HTTP instead?
The goal is to open an HTTP connection, do some requests and then upgrade to WebSocket. Right now this module conflates the client connection and upgrade in a single step.
Maybe we can reuse an HTTP connection to establish a WebSocket client?
A direct implementation may be to allow users to pass sock(
ngx.socket.tcp
) as an argument:and then we may do this:
(The code is for demonstration. It should be organized in a better way)