httprequest - POCO Request timeout even when keepAlive is set -
I am using a simple request request to get information from the server. I want to continue until the response is received from the server (this can be any 1 to 9 hours long). But I have to face the request expiration issue in 2 minutes. I am setting both sessions and requests as "setting". But it is not helping, I have also tried to use setKeepAliveTimeout and have given it a big value but I have not changed anything but using the code given below:
< Code> try {//} Prepare the request Poco :: URI (url); Const poco :: Net :: Context :: Ptr reference = New Poco :: Net :: Context (Poco :: Net :: Context :: CLIENT_USE, "", "", "", Poco :: Net :: Context: : VERIFY_NONE, 9, false, "All:! ADH:! Low:! XP:! MD5: @STRENGTH"); Poko :: Net :: HTTPSClient session session (uri.getHost (), uri.getPort (), context); Session.setKeepAlive (right); // path ready std :: string path (uri.getPathAndQuery ()); If (path.empty ()) {path = "/"; } // Send requests to Poco :: Net :: HTTPRequest req (Poco :: Net :: HTTPRequest :: HTTP_GET, Path, Poco :: Net :: HTTPMessage :: HTTP_1_1); Req.setKeepAlive (right); Session.sendRequest (requested); // Get feedback Poco :: Net :: HTTPResponse Res; // Get status status code = res.getStatus ()); // Get Status Status = res.getReason (); // Get body std :: istream & inStream = session.receiveResponse (res); Std :: ostringstream outStringStream; OutStringStream & lt; & Lt; InStream.rdbuf (); Feedback = outStringStream.str (); } Hold (Poko :: Exception and Exception) {cout & lt; & Lt; Exception.displayText (); }
Please tell me where I am wrong thanks.
I get position-1 timeout in about 2 minutes.
This question is somewhat old, but I have the answer and to find it, Will take time.
It is not the keepAlive setting that you want to change, because it only maintains open connections between requests.
Once you have requested
session.sendRequest (req);
(i.e. after the underlying socket of the session is installed), get the socket references of the session and change the timeout value received:
StreamSocket & Str = session.socket (); // Create one time time (for example) 600 seconds (10 minutes) timepane TS (600 L, 0L); Str.setReceiveTimeout (ts);
It worked for me!
Comments
Post a Comment