How to Keep the socket live

We are working on communicating between Filezilla Client and Filezilla Server having two proxies in between them. Between the two proxies we are having 2 tcp connection.

filezilla client -> P1 --2----- P2 -> filezilla server.

The problem we are getting is while upload filezilla client will send the entire data to P1 and P1 send the data to P2. But P2 recv. speed is not as fast as P1 sending speed. P1 will close the connection after some time but as the P2 is still trying to recv data from P1 so it will not be able to recv and it will fail.

Is there any way to keep the soket alive till the other end will recv the data completely?

I have tried using Linger with different timeout options. but it's not handling all the scenarios.

I have tried setting the socket option keepalive, but still the same problem persists.

Can anyone please help or suggest me something?
Topic archived. No new replies allowed.