HTTP request don't run on HTML5 package

Hi friends!!
I have got a problem with my code to catch a http request on HTML5 package.
ALL THIS CODE RUNS PERFECT IN THE UE EDITOR but when I package the project to HTML5 platform and I execute the package files the log shows this:

Timeout processing Http request

Connection error

The code does a petition to a server.
This is my code, it’s a fragment from a parent class of blueprint asset:

using UnrealBuildTool;

public class juangacedos_web : ModuleRules
{
	public juangacedos_web(TargetInfo Target)
	{
		PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" });

		PrivateDependencyModuleNames.AddRange(new string[] {  });

		PrivateDependencyModuleNames.AddRange(new string[] { "HTTP" });
            PrivateIncludePathModuleNames.AddRange(new string[] { "HTTP" });
}

In my .h file I have got this includes:

#include "Runtime/Online/HTTP/Public/Http.h"
#include "Runtime/Engine/Public/DDSLoader.h"
#include "Developer/ImageWrapper/Public/Interfaces/IImageWrapper.h"
#include "Developer/ImageWrapper/Public/Interfaces/IImageWrapperModule.h"

And My .cpp do this:

void ACOD_cargaObra::BeginPlay()
{
	Super::BeginPlay();

	TSharedRef < IHttpRequest > Request = FHttpModule::Get().CreateRequest();
	
	//Set Request
	Request->SetVerb("GET");
	Request->SetURL(ip + FString("query_obra.php?id=1"));
	GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, Request->GetURL());
	Request->OnProcessRequestComplete().BindUObject(this, &ACOD_cargaObra::PaginaLinkada);
	if (!Request->ProcessRequest()){
		GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Problem processing the request "));
	}
	
}

void ACOD_cargaObra::PaginaLinkada(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful){
	FString mensaje;
	FString cadena;
	FString valor;
	TArray <FString> atributos;
	int indice;

	if (bWasSuccessful){
		if (!Response.IsValid()){
			UE_LOG(LogTemp, Warning, TEXT("Response not is valid"));
		}
		else{
			//
			//
			//parsing the response
			//
			//
			mensaje = Response->GetContentAsString();
			TArray< FString > stringObras;
			numObras = mensaje.ReplaceInline(TEXT("///"), TEXT("///"), ESearchCase::IgnoreCase);
			mensaje.ParseIntoArray(&stringObras, TEXT("///"), false);
			for (int i = 0; i < stringObras.Num() - 1; i++){
				FString cadena = stringObras[i];
				for (int j = 0; j < ATRIBUTOS_CUADROS; j++){
					indice = cadena.Find(TEXT("|||"), ESearchCase::IgnoreCase, ESearchDir::FromStart, 0);
					atributos.Add(*cadena.Left(indice));
					cadena = *cadena.Right(cadena.Len() - (indice + 3));
				}
				COD_detalle_obra obra(FCString::Atoi(*atributos[0]), atributos[1],
					FCString::Atoi(*atributos[2]), FCString::Atoi(*atributos[3]),
					atributos[4], atributos[5], atributos[6], atributos[7]);
				obras.Add(obra);
				atributos.Reset();
			//
			//
			//
			//
			}
			GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, mensaje);
			//Event for the blueprint child
			this->OnQueryFinalizada(stringObras.Num()-1);
		}
	}
	else{
		UE_LOG(LogTemp, Warning, TEXT("Connection error"));
	}
}

Thanks!!

Hey Adr21112 -

Hows is your ip string structured - make sure its in the form of “http://x.x.x.x/” .

Hello Ankitkk!
Yes! This is my ip string:
FString ip = FString(“http://192.168.1.16:3334/”);
It’s the address of my local server. When I’m working in the UE Editor, the program does the connection successfully!!

Thanks!!

But this no it’s enough to run on html5
Some idea?
Thanks

Hey ,

What do you see in the browser console when you see this error occur? We have had multiple changes be integrated into 4.8, which may resolve the issue that you’re currently running into.

Looking forward to hearing back from you, thanks!

Hey :

When I run the project in web browser. it executes the BeginPlay(). When it launches the ProcessRequest(), the function bounds to OnProcessRequestComplete() waits few seconds. After, I see in the browser console:

[2015.05.22-06.40.14:734][945]LogHttp:Warning: Timeout processing Http request.

[2015.05.22-06.40.14:737][945]LogTemp:Warning: Connection error

Thanks for your attention!!

Hey ,

Thanks for providing me this information. We need the information from the actual browser’s console - - which would be to use ‘ctrl, shift j’. Information should start posting there once you’re attempting to launch your project.

Looking forward to hearing back from you, thanks!!

Hey !!
Excuse me, I didn’t know which console you were referred.
Ok: When I execute the game on HTML the 's console shows:

    Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://192.168.1.16:3334/query_obra.php?id=1. (Reason: CORS header 'Access-Control-Allow-Origin' missing).1 <unknown>

  
    Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://192.168.1.16:3334/query_obra.php?id=1. (Reason: CORS request failed).1 <unknown>

I tried with different urls and origins.
Thanks!!

Ok !! Thanks for your last post. I have searched information about CORS header. And I have found the error.
In the php file I must configure the header.
In my case, I put this:

<php
header('Access-Control-Allow-Origin: *');  
header('Access-Control-Allow-Methods: GET, POST');
header('Access-Control-Allow-Headers: content-type, pragma, x-unrealengine-agent');
--next code

Now, I go to see always the browser console!!! It’s very important :slight_smile:

Thanks for your clues!!