Download

HTTP module and long requests

I’m trying to work with PubNub subscriptions from a C++ code and faced strange issue - OnProcessRequestComplete function not executing if request took more than 10 sec to be completed.
I’ve tuned all timeouts in HTTP section of DefaultEngine.ini more than 200 sec
I’ve turned on veryverbose for LogHttp and do see:

.....HTTP code: 200, content length: 675, actual payload size: 675, elapsed: 10.09s
[2021.12.08-13.53.49:143][860]LogHttp: Verbose: 000001530D277200 Response Header Date: Wed, 08 Dec 2021 13:53:48 GMT
[2021.12.08-13.53.49:143][860]LogHttp: Verbose: 000001530D277200 Response Header Content-Type: text/javascript; charset="UTF-8"
[2021.12.08-13.53.49:143][860]LogHttp: Verbose: 000001530D277200 Response Header Content-Length: 675
[2021.12.08-13.53.49:143][860]LogHttp: Verbose: 000001530D277200 Response Header Connection: keep-alive
[2021.12.08-13.53.49:143][860]LogHttp: Verbose: 000001530D277200 Response Header Cache-Control: no-cache
[2021.12.08-13.53.49:143][860]LogHttp: Verbose: 000001530D277200 Response Header Access-Control-Allow-Origin: *
[2021.12.08-13.53.49:143][860]LogHttp: Verbose: 000001530D277200 Response Header Access-Control-Allow-Methods: GET
[2021.12.08-13.53.49:143][860]LogHttp: VeryVerbose: FHttpRequestImpl::OnProcessRequestComplete()

but function binded to the OnProcessRequestComplete wasn’t executed.
In case of replies quicker than 10sec - everything is OK.
No errors in LogHttp

Code itself:

UPubNubber::UPubNubber()
{
	bDoing = false;
	Http = &FHttpModule::Get();
	Http->SetHttpTimeout(160);
}

void UPubNubber::Start(FString NewToken, FString NewChannel, FString NewSubKey) {
	bDoing = true;
	Continue();
}

void UPubNubber::OnResponse(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful) {
	UE_LOG(LogPubNub, Log, TEXT("UPubNubber::OnResponse"));  /// Don't see this message if response came later than 10 sec
	if (bWasSuccessful) {
		if (bDoing) {
			Continue();
		}
	}
	else {
		bDoing = false;
	}
}

void UPubNubber::Continue() {
	TSharedRef<IHttpRequest, ESPMode::ThreadSafe> Request = Http->CreateRequest();
	Request->OnProcessRequestComplete().BindUObject(this, &UPubNubber::OnResponse);


	FString ReqUrl = TEXT("valid url");
	Request->SetURL(ReqUrl);
	Request->SetVerb("GET");
	Request->SetHeader(TEXT("Connection"), TEXT("keep-alive"));

	Request->ProcessRequest();
}

Don’t like that Continue() binds onResponse() which calls Continue() which binds onResponse()… but it works well for quick responses.
May be some timer for a BindObject thread?