The UWP project runs under the WIN10 system, and the network timeout occurs
Hello! We are a game developer, and the UWP project released by our game runs under WIN10 system, and the network timeout occurs. But this problem is useless under the WIN11 system, what is the reason for this?
Developer technologies | Universal Windows Platform (UWP)
-
Junjie Zhu - MSFT • 21,646 Reputation points
2023-06-26T08:10:29.2733333+00:00 Hi @yu xiao ,
Welcome to Microsoft Q&A!
What version of win10 are you testing now? Can the same problem be reproduced on other versions of Win10? If possible, please provide relevant code snippets for network timeouts so that we can further check the problem for you.
Thank you.
-
yu xiao • 0 Reputation points
2023-06-29T05:31:45.9433333+00:00 After calling GetVersionInfo, an en route error occurs
-
yu xiao • 0 Reputation points
2023-06-29T05:35:06.6066667+00:00 After calling GetVersionInfo, an en route error occurs
-
yu xiao • 0 Reputation points
2023-06-29T05:36:07.88+00:00 After calling GetVersionInfo, the error in the figure appears
-
yu xiao • 0 Reputation points
2023-06-29T05:41:31.86+00:00 Can you see the picture? If not, can you give me an email address?
-
yu xiao • 0 Reputation points
2023-06-29T05:43:18.64+00:00 Can you see the picture? If not, can you give me an email address?
-
Junjie Zhu - MSFT • 21,646 Reputation points
2023-06-29T07:56:07.8466667+00:00 You are not uploading an image. Please try to copy the error message and share it. Also ,could you please answer my questions in my pervious comment?
-
yu xiao • 0 Reputation points
2023-06-30T03:05:05.6033333+00:00 Hello! We are using win10 professional edition, and no problems have been found in other systems for the time being. Below is the code when the error occurs
// Copyright (c) Cragon. All rights reserved. using I2.Loc; using System; using System.Collections.Generic; using System.Runtime.CompilerServices; using System.Text; using System.Threading.Tasks; using Newtonsoft.Json; using UnityEngine; using UnityEngine.Networking; public enum GetVersionInfoState { Todo = 0, Doing, Done, } public static class ExtensionMethods { public static TaskAwaiter<object> GetAwaiter(this UnityWebRequestAsyncOperation op) { var tcs = new TaskCompletionSource<object>(); op.completed += (obj) => { tcs.SetResult(null); }; return tcs.Task.GetAwaiter(); } } public Class UnityWebRequestAwaiter { private async Task<Dictionary<string, string>> RequestPost(string url, string jsonArgs) { // 创建UnityWebRequest对象 Debug.Log($"url:{url}"); UnityWebRequest www = UnityWebRequest.PostWwwForm(url, ""); byte[] postBytes = Encoding.UTF8.GetBytes(jsonArgs); www.uploadHandler = new UploadHandlerRaw(postBytes); www.downloadHandler = new DownloadHandlerBuffer(); www.SetRequestHeader("Content-Type", "application/json"); // 发送请求并等待响应 await www.SendWebRequest(); // 处理响应 if (www.result != UnityWebRequest.Result.Success) { Debug.Log(www.error); return null; } else { var str_ret = www.downloadHandler.text; Debug.Log($"Form Post complete: {str_ret}"); return (JsonConvert.DeserializeObject<Dictionary<string, string>>(str_ret)); } } private async Task<Dictionary<string, string>> RequestGet(string url) { // 创建UnityWebRequest对象 Debug.Log($"url:{url}"); UnityWebRequest www = UnityWebRequest.Get(url); www.downloadHandler = new DownloadHandlerBuffer(); // 发送请求并等待响应 await www.SendWebRequest(); // 处理响应 if (www.result != UnityWebRequest.Result.Success) { Debug.Log(www.error); return null; } else { var str_ret = www.downloadHandler.text; Debug.Log($"Form Get complete: {str_ret}"); return (JsonConvert.DeserializeObject<Dictionary<string, string>>(str_ret)); } } //获取版本信息 async Task GetVersionInfo() { try { string url = $"http://127.0.0.1:5000/api/ccenter/getcfg?name_space=Guaji.Client"; //使用UnityWebRequest创建一个新的POST请求 var MapCfgFromCCenter = await RequestPost(url,""); /////////////////////////////////////////////////////////// // 如果连接Ccenter失败 就往Oss拿公告信息 if (MapCfgFromCCenter == null || MapCfgFromCCenter.Count == 0) { Debug.Log("-CCenter挂了,确认继续尝试"); return; } Debug.Log("Updater从CCenter获取配置信息"); foreach (var i in Updater.MapCfgFromCCenter) { Debug.Log($"{i.Key}={i.Value}"); } // 维护公告 string maintenance_switch = Updater.MapCfgFromCCenter["MaintenanceSwitch"]; if (maintenance_switch == "1") { string maintenance_info = Updater.MapCfgFromCCenter["MaintenanceInfo"]; ShowUiMsgBox(maintenance_info); return; } State = GetVersionInfoState.Done; } catch (Exception ex) { ShowUiMsgBox(ex.ToString()); } } }
-
Anonymous
2023-06-30T06:59:59.0133333+00:00 Could you please tell us which line of code will give you time out? Also, have you tried to send the same request in fiddler to see if it will give the same behavior on the same device?
Fiddler is a web debug tool that could detect the http request sent from your device.
postman is an API tool that can be used to simulate http requests.
-
yu xiao • 0 Reputation points
2023-06-30T08:45:33.43+00:00 “var MapCfgFromCCenter = await RequestPost(url,"");”
Execution here will timeoutWhat does ''fiddler'' mean?
-
Anonymous
2023-06-30T10:08:05.5433333+00:00 Fiddler is a web debug tool that could detect the http request sent from your device.
Postman is an API tool that can be used to simulate http requests.
Is your app a native UWP app or a unity converted app?
Please make sure the Http request works correctly out of the app
-
yu xiao • 0 Reputation points
2023-06-30T12:05:20.7466667+00:00 Let's debug again
-
Junjie Zhu - MSFT • 21,646 Reputation points
2023-07-10T08:43:21.9866667+00:00 Hi @yu xiao ,
Haven't heard from you for a while, any progress on your debugging?
Sign in to comment