Sending request with tcp connection

#1

Hi all,

I’m developing a new plugin that reads the request/response bodies and use tcp to send them to external service. But currently i’m able to open a tcp connection only per request.
Is there an option to keep a tcp connection open?

Thanks

1 Like
#2

Easiest to study the Kong open source plugins for ideas, here is how you keep a tcp socket connection alive:

Best,
-Jeremy

#3

@jeremyjpj0916 the mentioned solution only keeps a tcp connection alive for the current request scope,
so for each request a new tcp connection will be opened.
My question was is there a way to keep the connection alive between different handler requests?

#4

That is not my understanding of the underlying ngx socket connection lua hooks into. I believe it will continue to leverage the same tcp connection for the duration of the keepalive timeout across multiple independent requests. Maybe someone from Kong can shed more insight there for yah or correct me if I am mistaken.