Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

InvalidOperationException: Cannot override system-specified headers #1

Open
imyoungyang opened this issue Nov 20, 2017 · 12 comments
Open

Comments

@imyoungyang
Copy link

The code can't execute on Unity 2017.2.0f3

This issue is related to this issue:
aws/aws-sdk-net#643

The error message is as the following:

InvalidOperationException: Cannot override system-specified headers
UnityEngine.Networking.UnityWebRequest.SetRequestHeader (System.String name, System.String value) (at /Users/builduser/buildslave/unity/build/artifacts/generated/common/modules/UnityWebRequest/WebRequestBindings.gen.cs:511)
UnityEngine.WWW..ctor (System.String url, System.Byte[] postData, System.Collections.Generic.Dictionary`2 headers) (at /Users/builduser/buildslave/unity/build/Runtime/WebRequestWWW/UWRWWW.cs:62)
Amazon.Runtime.Internal.UnityMainThreadDispatcher+d__7.MoveNext () (at E:/JenkinsWorkspaces/v3-stage-release/AWSDotNetPublic/sdk/src/Core/Amazon.Runtime/Pipeline/_unity/UnityMainThreadDispatcher.cs:135)
UnityEngine.SetupCoroutine.InvokeMoveNext (IEnumerator enumerator, IntPtr returnValueAddress) (at /Users/builduser/buildslave/unity/build/Runtime/Export/Coroutines.cs:17)
UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
Amazon.Runtime.Internal.UnityMainThreadDispatcher:ProcessRequests() (at E:/JenkinsWorkspaces/v3-stage-release/AWSDotNetPublic/sdk/src/Core/Amazon.Runtime/Pipeline/_unity/UnityMainThreadDispatcher.cs:73)
Amazon.Runtime.Internal.UnityMainThreadDispatcher:Update() (at E:/JenkinsWorkspaces/v3-stage-release/AWSDotNetPublic/sdk/src/Core/Amazon.Runtime/Pipeline/_unity/UnityMainThreadDispatcher.cs:59)

@sapessi
Copy link

sapessi commented Dec 6, 2017

I've managed to resolve this by overriding the HTTP client the SDK uses. From the first behavior the application uses, before any call is made to AWS, you can set the AWSConfigs property:

AWSConfigs.HttpClient = AWSConfigs.HttpClientOption.UnityWebRequest;

@daveProgramming
Copy link

Where do I put this code?

@sapessi
Copy link

sapessi commented Dec 18, 2017

@daveProgramming I added this to the first behavior loaded by the game. The AWSConfigs contains static variables so once it's set it should be re-used by all other instances of the SDK.

@OverworldOwl
Copy link

Seems to work for me. Thanks!

@thedanitime
Copy link

I had that problem too, thanks!

@Legogo
Copy link

Legogo commented Jul 5, 2018

I added
AWSConfigs.HttpClient = AWSConfigs.HttpClientOption.UnityWebRequest;
in the Start() function of the S3Example.cs like so

    void Start()
    {
        UnityInitializer.AttachToGameObject(this.gameObject);
        GetBucketListButton.onClick.AddListener(() => { GetBucketList(); });
        PostBucketButton.onClick.AddListener(() => { PostObject(); });
        GetObjectsListButton.onClick.AddListener(() => { GetObjects(); });
        DeleteObjectButton.onClick.AddListener(() => { DeleteObject(); });
        GetObjectButton.onClick.AddListener(() => { GetObject(); });

        AWSConfigs.HttpClient = AWSConfigs.HttpClientOption.UnityWebRequest;
    }

And it seems to work. At least in 2018.1.3 editor.

@jlankitus
Copy link

Hey all,

This worked great for me in Windows! However this seems to crash webgl. Anyone have alternatives to this for WebGL or know if its impossible?

@chen1013
Copy link

chen1013 commented Sep 8, 2018

I'm using the Cognito service. This works for me as well. Thank you sooooo much!

@yongyili
Copy link

This also works for me in Mac and I am using the GameLift service.
Thanks a lot.

@tsogtbayar123
Copy link

It works after adding Legogo's code in start function. thnx a lot.

@jmdjr
Copy link

jmdjr commented Apr 25, 2020

The line of code speficied doesn't seem to work in the latest version, could be that, at least with the assets in the Chess game example, AWSConfigs does not contain HttpClient

@MobileAppsFirst
Copy link

MobileAppsFirst commented Mar 21, 2021

With aws-sdk-unity_3.3.802.0 and Unity 2019.4.18f1 it seems that the solution with HttpClient is not working. Does anyone have an idea how to fix this?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests