The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.
1 2 3 4 5 6 7 8 9 |
void Start() { UnityInitializer.AttachToGameObject(this.gameObject); // この行を追加 AWSConfigs.HttpClient = AWSConfigs.HttpClientOption.UnityWebRequest; InvokeButton.onClick.AddListener(() => { Invoke(); }); ListFunctionsButton.onClick.AddListener(() => { ListFunctions(); }); } |
1 2 3 4 5 6 |
void Awake() { UnityInitializer.AttachToGameObject (this.gameObject); gameObject.AddComponent<CustomUnityMainThreadDispatcher>(); AWSConfigs.HttpClient = AWSConfigs.HttpClientOption.UnityWebRequest; } |
UnityEditorからUnityWebRequest(AWSSDKを使用せずシンプルなコードで)を使って送信内容を確認してみると、Unity2017.3.0p4にのみTransfer-Encoding: chunkedのHeader情報が追加されていました。どうやらこの影響で、エラーが発生しているようなのです。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
var http = require('http'); var server = http.createServer(function(req, res) { console.log("================"); console.log(req.method); var body = ''; req.on('data', function(data) { body += data; }); req.on('end', function() { console.log("body=[" + body + "]"); }); console.log(JSON.stringify(req.rawHeaders)); console.log("---"); for (var i = 0; i < req.rawHeaders.length / 2; i++) { console.log(req.rawHeaders[(i*2)] + ":" + req.rawHeaders[(i*2)+1]); } console.log("---"); res.writeHeader(200, { 'Content-Type': 'text/plane' }); res.write(JSON.stringify(req.rawHeaders)); res.end(); return ; }).listen(80); |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using UnityEngine.Networking; public class WebRequestTest : MonoBehaviour { [SerializeField] Text _text; string uri = "http://xxx.xxx.xxx.xxx”; // 接続先のIPアドレス // Use this for initialization void Start () { } IEnumerator HttpRequestGet() { var request = UnityWebRequest.Get(uri); //request.chunkedTransfer = false; yield return request.Send(); Debug.Log(request.responseCode.ToString() + ":" + request.downloadHandler.text); _text.text = request.downloadHandler.text; } IEnumerator HttpRequestPost(string data) { var request = UnityWebRequest.Post(uri, data); //request.chunkedTransfer = false; yield return request.Send(); Debug.Log(request.responseCode.ToString() + ":" + request.downloadHandler.text); _text.text = request.downloadHandler.text; } public void OnSendGet() { _text.text = ""; StartCoroutine(HttpRequestGet()); } public void OnSendPost01() { _text.text = ""; StartCoroutine(HttpRequestPost("")); } public void OnSendPost02() { _text.text = ""; StartCoroutine(HttpRequestPost("hello")); } public void OnSendPost03() { _text.text = ""; StartCoroutine(HttpRequestPost("6\nHelloWorld\n5\n 0\n")); } } |
1 2 3 4 5 6 7 |
Host:xxx.xxx.xxx.xxx(ここにはホストのIPアドレスが入っている) Connection:keep-alive Accept:*/* User-Agent:testapp/0 CFNetwork/894 Darwin/17.4.0 Accept-Language:ja-jp Accept-Encoding:gzip, deflate X-Unity-Version:2017.3.0p4 |
1 2 3 4 5 6 7 8 9 |
Host:xxx.xxx.xxx.xxx Content-Type:application/x-www-form-urlencoded Content-Length:0 Connection:keep-alive Accept:*/* User-Agent:testapp/0 CFNetwork/894 Darwin/17.4.0 Accept-Language:ja-jp Accept-Encoding:gzip, deflate X-Unity-Version:2017.3.0p4 |
1 2 3 4 5 6 7 8 9 |
Host:xxx.xxx.xxx.xxx Content-Type:application/x-www-form-urlencoded X-Unity-Version:2017.3.0p4 Connection:keep-alive Accept:*/* Accept-Language:ja-jp User-Agent:testapp/0 CFNetwork/894 Darwin/17.4.0 Accept-Encoding:gzip, deflate Transfer-Encoding:chunked |
1 2 3 4 5 6 7 8 9 |
Host:xxx.xxx.xxx.xxx Content-Type:application/x-www-form-urlencoded X-Unity-Version:2017.3.0p4 Connection:keep-alive Accept:*/* Accept-Language:ja-jp User-Agent:testapp/0 CFNetwork/894 Darwin/17.4.0 Accept-Encoding:gzip, deflate Transfer-Encoding:chunked |