x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

Http Request on iOS

I am trying to perform a very simple GET request on iOS. I just want to get the response from a PHP page that I have created to access a database. The code works perfectly on Andoid, Windows and OSX but causes a crash immediately as it's called on iOS. I've been trying to figure this out for about a month now and it's killing me. I will be so incredibly happy if someone knows what is going wrong.

The code I'm using is below.

Header .h file:

 //Send an HTTP Get request
 UFUNCTION(BlueprintCallable, Category = "SBNetworking")
 bool SendGetRequest(FString TheHost);

 //this is called when data is received.
 void HTTPOnResponseReceived(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful);

 //This is an event callable in BP that fires when HTTP data is received
 UFUNCTION(BlueprintImplementableEvent, meta = (FriendlyName = "Http Request Data Received"))
 void HTTPRequestDataReceived(const FString& HttpData);

.cpp File:

 //Perform a simple get request
 bool ASandboxNetworkActor::SendGetRequest(FString TheHost){
     FHttpModule* HttpMod = &FHttpModule::Get();
     if (!HttpMod) { return false; }
     if (!HttpMod->IsHttpEnabled()) { return false; }
 
     FString TargetHost = TheHost;
     TSharedRef <IHttpRequest> Request = HttpMod->CreateRequest();
     Request->SetVerb("GET");
     Request->SetURL(TargetHost);
     Request->SetHeader("User-Agent", "SandboxNetworkAgent/1.0");
     Request->SetHeader("Content-Type", "text/html");
 
     Request->OnProcessRequestComplete().BindUObject(this, &ASandboxNetworkActor::HTTPOnResponseReceived);
     if (!Request->ProcessRequest()) { return false; }
 
     return true;
 }
 
 void ASandboxNetworkActor::HTTPOnResponseReceived(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful)
 {
     this->HTTPRequestDataReceived(Response->GetContentAsString());
 }
 
 void HTTPRequestDataReceived(const FString& HttpData){
     
 }


If there is another way of doing this I am totally open to suggestions!!! I tried creating a fresh project and adding the code to test it out. It crashed as expected. I have "HTTP" added to my public and private dependencies in build.cs and #include "Http.h" in my header file. Once again it works on all platforms I've tested but iOS.

Here is the crash log:

Crash log txt file

Thank you so much for any help you can offer. I am truly desperate and cannot move any further on 2 of my projects without this functionality.

Product Version: UE 4.10
Tags:
more ▼

asked Jan 27 '16 at 04:35 AM in C++ Programming

avatar image

tehhax
194 31 29 51

avatar image Shadowriver Jan 27 '16 at 05:57 AM

The crash stack dump are not very helpful, they missing symbol data (what address correspond to what line in cpp file) you can see those in iOS libraries

 2   libsystem_pthread.dylib           0x226430f9 pthread_cond_timedwait + 45

but not in UE4 modules, all you get is memory address

 4   FirstPersonSandbox49              0x03563a91 0x4000 + 55966353

Without that this crash raports tells nothing

Do you use launcher iOS UE4 build? If not, try to compile debug build and run it, it should have symbols then... i think i never worked with iOS or OSX. Without that it hard to debug crashes

Alternativly you could try see logs (again i don't know how you do it in iOS), this might be some controlled crash (UE4 is design to crash it self in controllable way when issue is detected, insted of letting it crash it self without much data), like assert error, not to mention looking on stack dump

 0   libsystem_kernel.dylib            0x225a1c84 __pthread_kill + 8
 1   libsystem_pthread.dylib           0x22643b47 pthread_kill + 63
 2   libsystem_c.dylib                 0x225380c5 abort + 109
 3   FirstPersonSandbox49              0x00493ee5 0x4000 + 4783845

it look like UE4 killed it self (UE4 clearly called function "abort" by itself) so it might left his "suicide note" in logs :p

avatar image tehhax Jan 27 '16 at 06:33 AM

Hey thanks so much for the response! I grabbed those crash logs from the device manager in XCode which is all i could find. I think it attempts to symbolify it. If there is some way to get the symbol data that would be more helpful then please let me know and I will get it right away!

I have tried building/running from XCode. I build/run the editor in XCode then launch on the device from the editor. I have also tried packaging with no luck. I can get other C++ code to work on iOS but this function just crashes instantly.

If there is any way to get better debug information from these crashes please let me know! I had no idea what to make of these crash logs and was hoping they would be of some use.

Do you know how (or if) I can find the UE4 suicide note from the iPad? That would be amazingly helpful :)

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

Oh wow I finally got it to work. Thank you so much Shadowriver for showing me NSLog! That gave me the output I needed to figure out what was actually going wrong! I needed to allow an exception for the connection I'm making in the plist.

I just added this to the "additional plist data" section in project settings->ios (this is for google.ca for example):

 <key>NSAppTransportSecurity</key><dict><key>NSExceptionDomains</key><dict><key>google.ca</key><dict><!--Include to allow subdomains--><key>NSIncludesSubdomains</key><true/><!--Include to allow HTTP requests--><key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key><true/><!--Include to specify minimum TLS version--><key>NSTemporaryExceptionMinimumTLSVersion</key><string>TLSv1.1</string></dict></dict></dict>

I removed the line breaks from above. You are amazing Shadowriver!

Edit: I am converting this to answer and marking it for future people having this problem.

more ▼

answered Jan 27 '16 at 12:31 PM

avatar image

tehhax
194 31 29 51

avatar image calembendell Mar 02 '18 at 03:14 PM

Nice! For some reason this isn't the answer, which could be confusing to readers. Could you mark this as the answer?

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

Well you would need to build debug version of engine, which means you need to build it from source. But try to get log first, since for me looking on what i can read from this crash now it is controlled crash.

i don't know how to get the logs in iOS, i don't know how devlopment looks there, but i my guess is you can watch logs in some of iOS debug tools in XCode. In case of Android UE4 it prints logs in to central system log called logcat, which you can see using ADB or Android monitor tool, so the same probably is with iOS, there might be tool for that. I trying to google but i can't find much, this might direct you somewhere:

http://stackoverflow.com/questions/355802/whats-the-best-way-to-log-debug-info-in-an-iphone-app

UE4 definitly uses NSLog to print anything: https://github.com/EpicGames/UnrealEngine/blob/97c8d3ef55e869e17ef149903eae2a33101381c9/Engine/Source/Runtime/Core/Private/IOS/IOSPlatformMisc.cpp#L138

more ▼

answered Jan 27 '16 at 06:46 AM

avatar image

Shadowriver
36.6k 931 169 1111

avatar image tehhax Jan 27 '16 at 07:28 AM

Oh wow you are amazing thank you so much for pointing out NSLog!! I am brand new to OSX and apparently there is a little triangle at the bottom left of the device manager that shows the console. I am not sure if I enabled it in Xcode -> preferences or if it was there all along. It's showing now and that's what matters. Now I have an actual error to work with!

The error begins right after "Network Actor Spawned": NSLog output txt file

It looks like

 "Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file." 

is the source of the problem. It looks like the HTTP request was blocked and is causing a crash. What do I need to do to my Info.plist file to allow this?

nslog output.txt (3.4 kB)
avatar image Shadowriver Jan 27 '16 at 04:09 PM

Ok then i conver my comment to anwser then

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question