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"

localhost Not Serving

Hello!

The game runs great until it gets to the point where I submit my score to a leaderboard, thats when the HTML5LaunchHelper.exe displays the 'Not Serving' message and the score never gets submitted.

alt text

The score is submitted using the HTTP Post request below:

.h

 #pragma once
 
 #include "GameFramework/Actor.h"
 #include "Runtime/Online/HTTP/Public/Http.h"
 #include "HttpRequest.generated.h"
 
 UCLASS(ClassGroup = (Custom), meta = (BlueprintSpawnableComponent))
 class BLINDSCOMGAME_API UHttpRequest : public UActorComponent
 {
     GENERATED_BODY()
     
 public:    
     FHttpModule* Http;
 
     //UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Custom)
     //FString URLName;
 
     // The actual HTTP call
     UFUNCTION(BlueprintCallable, Category=Custom)
     void MyHttpCall(FString URLName);
 
     // Assign this function to call when the GET request processes sucessfully
     void OnResponseReceived(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful);
 
     // Set Default Values for this Actor's properties
     UHttpRequest(const class FObjectInitializer& ObjectInitializer);
 
     // Called when the game starts or when spawned
     virtual void BeginPlay() override;
 };
 


.cpp

 #include "Game.h"
 #include "HttpRequest.h"
 
 
 // Sets default values
 UHttpRequest::UHttpRequest(const class FObjectInitializer& ObjectInitializer)
     : Super(ObjectInitializer)
 {
     // When the object is constructed, get the HTTP module
     Http = &FHttpModule::Get();
 }
 
 // Called when the game starts or when spawned
 void UHttpRequest::BeginPlay()
 {
     Super::BeginPlay();
 }
 
 // HTTP CALL
 void UHttpRequest::MyHttpCall(FString URLName)
 {
     TSharedRef<IHttpRequest> Request = Http->CreateRequest();
     Request->OnProcessRequestComplete().BindUObject(this, &UHttpRequest::OnResponseReceived);
     Request->SetURL(URLName);
     Request->SetVerb("POST");
     //Request->SetHeader(TEXT("User-Agent"), "X-UnrealEngine-Agent");
     //Request->SetHeader("Content-Type", TEXT("application/json"));
     Request->ProcessRequest();
 }
 
 //Assigned function on successfull http call
 void UHttpRequest::OnResponseReceived(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful)
 {
     //Create a pointer to hold the json serialized data
     TSharedPtr<FJsonObject> JsonObject;
 
     //Create a reader pointer to read the json data
     TSharedRef<TJsonReader<>> Reader = TJsonReaderFactory<>::Create(Response->GetContentAsString());
 
     //Deserialize the json data given reader and the actual object to deserialize
 
     if (FJsonSerializer::Deserialize(Reader, JsonObject))
     {
         //Get the value of the json object by field name
         int32 recievedInt = JsonObject->GetIntegerField("seconds");
 
         //Output it to the engine
         GEngine->AddOnScreenDebugMessage(1, 2.0f, FColor::Green, FString::FromInt(recievedInt));
     }
 }

Anyone else experience this problem or something similar? I've got no idea what is causing the host not to serve the URL

Any and all ideas are welcome!

Product Version: UE 4.14
Tags:
notserving.jpg (215.4 kB)
more ▼

asked Jan 04 '17 at 09:50 PM in Packaging & Deployment

avatar image

HaxO
713 23 15 45

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

hello haxo

the URL you are accessing is external to the "original" host (local or webhosted -- doesn't matter) -- the URL you've passed in is "relative" to the "original" host.

for example, you are using URL: "dreamlo.com/lb/secret-key/add/bla/bla/bla.."

this is NOT the same as using URL: "http://dreamlo.com/lb/secret-key/add/bla/bla/bla..."

that should fix your issue. (just in case it's not obvious -- use the 2nd URL example above -- the one with the "http://" protocol in front)

more ▼

answered Jan 09 '17 at 10:43 PM

avatar image

nick.shin STAFF
476 5 4 9

avatar image HaxO Jan 10 '17 at 03:08 PM

Thanks for the answer Nick! That did get rid of my 'Not Serving' error. The score still isn't making it onto the dreamlo leaderboard though.

I know MyHttpCall works in a PC build and in the editor. Wonder what is stopping it on HTML5.

(comments are locked)
10|2000 characters needed characters left
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