Changing defaultengine.ini for a plugin

Hi, I’m working on a project which relies on HTTP requests to grab data from a server. The problem I encountered was that the HTTP requests I was sending were incredibly slow. Some searching found that I was not the only one and I managed to find a decent solution to the main issue with the top rated answer here. I added the following to Defaultengine.ini and instantly my HTTP requests were grabbing data at a speed I was expecting:


My issue is that I’m working on a plugin that we want to distribute. Is there a way for me to have this done for anyone using our plugin automatically rather than having them have to change the ini file each time they start a new project? Perhaps some way of having a DefaultEngine.ini in the plugin folder?

I am not aware of any built in feature that enables you to include an override file only for your plugin.
So I think you have to directly change the DefaultEngine.ini file of the current project.

To do this you could do the following:

(In a header file, with generated header included)

UCLASS(Config=Engine, PerObjectConfig)
class UConfigFake : public UObject

	float HttpThreadActiveFrameTimeInSeconds{ 0.00001 };

	virtual void OverridePerObjectConfigSection(FString &SectionName) override 
        SectionName = TEXT("HTTP"); 

Then, whenever you want to write this value to the ini file, you need to execute the following code:

void WriteConfigProperties(const FString &iniFilePath)
	auto *fakeConfig{ NewObject<UConfigFake>() };
	fakeConfig->SaveConfig( CPF_Config, GetData( iniFilePath ) );    

This will write the values of all UPROPERTY(config) members of the object instance into the ini file at iniFilePath, listing them under the section that is assigned inside OverridePerObjectConfigSection.

In your case, the call to WriteConfigProperties could look as following, if you want to output into the per project DefaultEngine.ini

WriteConfigProperties( FPaths::ProjectConfigDir() + TEXT("DefaultEngine.ini") );	

For instance, you could do this for editor builds in a EngineSubsystem’s Initialize function (if you don’t need to support versions prior to 4.22, where Subsystems were added)

Please be aware that this solution ‘abuses’ the current behavior of the PerObjectConfig system, so it may break in future versions. Also, this is a very specialized solution I only suggest because this part of the http config seems not to be exposed to the project settings system. I think you should inform your plugin users about the fact that you set this property (e.g. via a log) or not override it in case its already set (look into UObject::LoadConfig for that).

I hope this helps or at least gives you some clues on how to continue.

1 Like

Alternate approach utilizing c# script when building plugin.
add this to your and then delete Binaries, Intermediate folders from your plugin directory and re-build the plugin.

//Fix slow HTTP download.
string txtPath = Path.GetFullPath(Path.Combine(Target.ProjectFile.Directory.ToString(), "Config", "DefaultEngine.ini"));
string fixLine = "\n[HTTP.Curl]\nBufferSize=524288\n[HTTP]\nHttpThreadActiveFrameTimeInSeconds=0.00001";
    File.AppendAllText(txtPath, fixLine);

So, if users download your plugin, it will run automatically when they build it before opening the project.
However, if they only enable the plugin and use auto restart, the configuration may not work the first time.