Game crashing when failing to connect to internet

Hi.
At the start of the game, I connect my game to a website to fetch stuff. But, since I upgraded to 4.7, the game has started to crash when there is no internet connection. The crash happens in editor as well as in the build. This is what the crash report looks like:

I have also tried stuff like FHttpModule::Get().SetHttpTimeout(2.0f); to do a timeOut. Here is what my request code looks like (the following code works fine when internet connection is established):

FSagRequest CurrentRequest;  //Custom made struct

FString Dest;


FHttpModule::Get().SetHttpTimeout(2.0f);
TSharedRef<IHttpRequest> Request = FHttpModule::Get().CreateRequest();

Request->SetHeader("Content-Type", "text/html");

Request->SetURL(TEXT("http://xyz.com/abc.php"));
Request->SetVerb(TEXT("POST"));




CurrentRequest.AddURLPair("BuildNo", BuildVersion);


Request->SetContentAsString(CurrentRequest.TheData);

Request->OnProcessRequestComplete().BindUObject(this, &AHTTPHandlerActor::OnResponseReceivedQuotes);




if (!Request->ProcessRequest())
{
	
	return false;
}


return true;

Any help would be greatly appreciated

Ran into this issue too. Killing demoing my game!

Yeah this broke the game for me when I was showing it at GDC!!

OMG me too! Also during GDC!

void AHTTPHandlerActor::OnResponseReceivedQuotes(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful)
{
FString MessageBody = “”;

if (!Response.IsValid())
{
	MessageBody = "{\"success\":\"Error: Unable to process HTTP Request!\"}";
}
else if (EHttpResponseCodes::IsOk(Response->GetResponseCode()))
{
	MessageBody = Response->GetContentAsString();
	
	
	ResponseError = 0;

}
else
{
	MessageBody = FString::Printf(TEXT("{\"success\":\"HTTP Error: %d\"}"), Response->GetResponseCode());
}

ResponseStr = TCHAR_TO_UTF8(*MessageBody);

}

I tried to step through the blueprint where the call to connect to the internet is being made. It did not crash over there, but crashed once the whole onBeginPlay was over. I can`t find the place it is crashing at. The problem is that the check to establish the connection is not being done in a loop. That happens just ONCE!!!

Have you tried to debugging the code? Whats the code for the

HTTPHandlerActor::OnResponseReceivedQuote

?

Hey everyone-

Thanks for reporting this crash. We are currently investigating what’s causing the issue (UE-12225) and will update you here with more information when we have a better understanding of the cause.

Cheers

Hi. In the meantime, is there a quick function that can check if the system is connected to internet (like a ping to google), so that I can quickly disconnect my http request on detecting lack of connectivity.
Thanks.

Hey -

Unfortunately there no easy way to distinguish between the system having a completely dead internet connection and issues such as the server being pinged being down.

Hello, is there a way to check whether the connection is dead or the server pinged is down? :slight_smile: I don’t really care to distinguish between those two, I’m just ok if I can distinguish between [I can / I cannot] reach the server.

Hey ocramot-

I’m not sure exactly what you’re asking. If you ping the server initially, it should return if it was able to reach it or not (if there is no internet connection then it would not reach the server). If you have further questions, it would be best to open a new post as this was specifically in reference to a crash when trying to connect with no internet connection. By separating the post it helps keep the information related to one issue from being lost within the conversation of another issue.