lua-resty-http2 icon indicating copy to clipboard operation
lua-resty-http2 copied to clipboard

如何复用TCP连接?

Open piaoxuebingfeng opened this issue 4 years ago • 3 comments
trafficstars

HTTP2 针对TCP连接是多路复用的,但是我使用 lua-resty-http2 发起的tcp连接没有办法实现多路复用。

请问文档中描述的 client:keepalive 接口该如何使用?我按照文档的方法测试,发现还是会创建新的tcp连接

piaoxuebingfeng avatar Jan 19 '21 07:01 piaoxuebingfeng

我主要是想利用 lua-resty-http2 这个模块实现一个h2代理,达到的效果是,代理与客户端之间运行的http2协议维持的是一个TCP连接,代理与后端服务器之间运行http2协议维持的也是一个TCP连接。

piaoxuebingfeng avatar Jan 19 '21 07:01 piaoxuebingfeng

You may try to create a timer, which accepts requests from requests in the same worker, the timer opens one connection to upstream by the HTTP/2 multiplex mechanism, and backs the response to the correct request.

tokers avatar Jan 20 '21 01:01 tokers

You may try to create a timer, which accepts requests from requests in the same worker, the timer opens one connection to upstream by the HTTP/2 multiplex mechanism, and backs the response to the correct request.

I don't quite understand what you mean,can you give me a demo about how to use h2 multiplex mechanism ,thanks a lot.

piaoxuebingfeng avatar Jan 26 '21 05:01 piaoxuebingfeng