lith 4 年之前
父節點
當前提交
904073e011

+ 7 - 0
dotnet/Gateway/App.Gateway/appsettings.json

@@ -19,6 +19,13 @@
           /* 服务端 监听端口号。例如: 4501 */
           "port": 4501,
 
+
+          /* 请求超时时间(单位ms,默认300000) */
+          "requestTimeoutMs": 300000,
+
+          /* 后台处理消息的线程个数(单位个,默认2) */
+          "workThreadCount": 2,
+
           //HeartBeat
           /* 心跳检测时间间隔(单位ms,默认10000,若指定为0则不进行心跳检测) */
           "heartBeatIntervalMs": 10000,

+ 16 - 17
dotnet/Gateway/Sers.Gateway/Sers.Gateway/GatewayHelp.cs

@@ -242,9 +242,20 @@ namespace Sers.Gateway
         static readonly string ResponseDefaultContentType = ConfigurationManager.Instance.GetStringByPath("Sers.Gateway.WebHost.ResponseDefaultContentType") ?? Response_ContentType_Json;
         async Task WriteApiReplyMessage(HttpResponse response,ApiMessage apiReply)
         {
-            var replyRpcData = GetReplyRpcData();
+            RpcContextData replyRpcData = null;
 
-            #region (x.1)statusCode
+            #region (x.1)GetReplyRpcData
+            {
+                var rpcContextData_OriData = apiReply.rpcContextData_OriData;
+                if (null != rpcContextData_OriData && rpcContextData_OriData.Count > 0)
+                {
+                    replyRpcData = RpcContextData.FromBytes(rpcContextData_OriData);
+                }
+            }
+            #endregion
+
+
+            #region (x.2)statusCode
             var statusCode = replyRpcData?.http.statusCode;
             if (statusCode.HasValue)
             {
@@ -253,7 +264,7 @@ namespace Sers.Gateway
             #endregion
 
          
-            #region (x.2) header
+            #region (x.3) header
             //(x.x.1)原始header
             var headers = response.Headers;
             if (replyRpcData?.http.headers != null)
@@ -263,7 +274,6 @@ namespace Sers.Gateway
                     headers[item.Key] = item.Value;
                 }
             }
-
             
             //(x.x.2)Content-Type → application/json
             if (!headers.ContainsKey("Content-Type"))
@@ -274,25 +284,14 @@ namespace Sers.Gateway
             #endregion
  
 
-            //(x.3) Body
+            //(x.4) Body
             var seg = apiReply.value_OriData;
             if (seg.Array != null && seg.Count > 0)
             {
                 await response.Body.WriteAsync(seg.Array, seg.Offset, seg.Count);
             }
 
-            #region function GetReplyRpcData
-            RpcContextData GetReplyRpcData()
-            {
-                var rpcContextData_OriData = apiReply.rpcContextData_OriData;
-                if (null != rpcContextData_OriData && rpcContextData_OriData.Count > 0)
-                {
-                    return RpcContextData.FromBytes(rpcContextData_OriData);  
-                }
-                return null;
-            }
-
-            #endregion
+           
         }
 
         #endregion

+ 2 - 2
dotnet/Library/Sers/Sers.CL/Test/CommunicationManage/CmClient/appsettings.json

@@ -5,8 +5,8 @@
       /* 共用配置,子项共用,覆写子项未指定的配置 */
       "Config": {
 
-        /* 请求超时时间(单位ms,默认60000) */
-        "requestTimeoutMs": 60000,
+        /* 请求超时时间(单位ms,默认300000) */
+        "requestTimeoutMs": 300000,
 
         /* 后台处理消息的线程个数(单位个,默认2) */
         "workThreadCount": 16,

+ 2 - 2
dotnet/Library/Sers/Sers.CL/Test/CommunicationManage/CmServer/appsettings.json

@@ -5,8 +5,8 @@
       /* 共用配置,子项共用,覆写子项未指定的配置 */
       "Config": {
 
-        /* 请求超时时间(单位ms,默认60000) */
-        "requestTimeoutMs": 60000,
+        /* 请求超时时间(单位ms,默认300000) */
+        "requestTimeoutMs": 300000,
 
         /* 后台处理消息的线程个数(单位个,默认2) */
         "workThreadCount": 16,

+ 2 - 2
dotnet/Library/Sers/Sers.Core/Sers.Core/CL/CommunicationManage/CommunicationManageClient.cs

@@ -18,7 +18,7 @@ namespace Sers.Core.CL.CommunicationManage
         {
             defaultConfig= ConfigurationManager.Instance.GetByPath<JObject>("Sers.CL.Config")??new JObject();
 
-            requestTimeoutMs = defaultConfig["requestTimeoutMs"]?.ConvertBySerialize<int?>() ?? 60000;
+            requestTimeoutMs = defaultConfig["requestTimeoutMs"]?.ConvertBySerialize<int?>() ?? 300000;
         }
 
         private JObject defaultConfig;
@@ -28,7 +28,7 @@ namespace Sers.Core.CL.CommunicationManage
         IOrganizeConnection[] connList;
 
         /// <summary>
-        /// 请求超时时间(单位ms,默认60000)(Config.requestTimeoutMs)
+        /// 请求超时时间(单位ms,默认300000)(Config.requestTimeoutMs)
         /// </summary>
         public int requestTimeoutMs { get; }
 

+ 2 - 2
dotnet/Library/Sers/Sers.Core/Sers.Core/CL/CommunicationManage/CommunicationManageServer.cs

@@ -28,14 +28,14 @@ namespace Sers.Core.CL.CommunicationManage
         {
             defaultConfig = ConfigurationManager.Instance.GetByPath<JObject>("Sers.CL.Config") ?? new JObject();
 
-            requestTimeoutMs = defaultConfig["requestTimeoutMs"]?.ConvertBySerialize<int?>() ?? 6000;
+            requestTimeoutMs = defaultConfig["requestTimeoutMs"]?.ConvertBySerialize<int?>() ?? 300000;
         }
 
 
         private JObject defaultConfig;
 
         /// <summary>
-        /// 请求超时时间(单位ms,默认60000)(Config.requestTimeoutMs)
+        /// 请求超时时间(单位ms,默认300000)(Config.requestTimeoutMs)
         /// </summary>
         public int requestTimeoutMs { get; }
 

+ 5 - 5
dotnet/Library/Sers/Sers.Core/Sers.Core/CL/MessageOrganize/DefaultOrganize/RequestAdaptor.cs

@@ -169,9 +169,9 @@ namespace Sers.Core.CL.MessageOrganize.DefaultOrganize
         int workThreadCount = 2;
 
         /// <summary>
-        /// 请求超时时间(单位ms,默认60000)
+        /// 请求超时时间(单位ms,默认300000)
         /// </summary>
-        public int requestTimeoutMs = 60000;
+        public int requestTimeoutMs = 300000;
 
         /// <summary>
         /// 心跳检测超时时间(单位ms,默认30000)
@@ -219,8 +219,8 @@ namespace Sers.Core.CL.MessageOrganize.DefaultOrganize
         #region class DeliveryToOrganize_MessageFrame  DeliveryToOrganize_RequestInfo
         class DeliveryToOrganize_MessageFrame
         {
-            public IOrganizeConnection conn { get; set; }
-            public ArraySegment<byte>? messageFrame;           
+            public IOrganizeConnection conn;
+            public ArraySegment<byte>? messageFrame;
         }
 
 
@@ -259,7 +259,7 @@ namespace Sers.Core.CL.MessageOrganize.DefaultOrganize
 
                         if (OrganizeToDelivery_RequestMap_TryRemove(reqKey, out var requestInfo))
                         {
-                            requestInfo.callback(requestInfo.sender, new Vit.Core.Util.Pipelines.ByteData(replyData));                         
+                            requestInfo.callback(requestInfo.sender, new Vit.Core.Util.Pipelines.ByteData(replyData));
                         }
                         return;
                     }

+ 35 - 23
dotnet/Library/Sers/Sers.Core/Sers.Core/Module/Api/LocalApi/StaticFileTransmit/StaticFileMap.cs

@@ -10,6 +10,21 @@ using System.Collections.Generic;
 
 namespace Sers.Core.Module.Api.LocalApi.StaticFileTransmit
 {
+
+    //Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(responseFileName, Encoding.UTF8));
+    //Response.AddHeader("Content-Length", new FileInfo(filePath).Length.ToString());
+    //Response.ContentType = (ContentType ?? MimeMapping(Path.GetExtension(responseFileName)));
+    //Response.ContentEncoding = Encoding.UTF8;
+    //Response.Charset = "utf-8";
+
+    // https://www.cnblogs.com/lonelyxmas/p/12441606.html
+    // https://www.cnblogs.com/Leo_wl/p/6059349.html
+
+    //Response.Headers.Append("Cache-Control", "public,max-age=600");
+    //(小知识: max - age:表示当访问此网页后的max - age秒内再次访问不会去服务器请求,其功能与Expires类似,只是Expires是根据某个特定日期值做比较。一但缓存者自身的时间不准确.则结果可能就是错误的,而max - age,显然无此问题.。Max - age的优先级也是高于Expires的。)
+
+
+
     public class StaticFileMap
     {
 
@@ -120,6 +135,12 @@ namespace Sers.Core.Module.Api.LocalApi.StaticFileTransmit
         }
 
 
+
+
+        #region TransmitFile
+
+      
+
         public byte[] TransmitFile()
         {
             return TransmitFile(GetAbsFilePath());
@@ -128,10 +149,11 @@ namespace Sers.Core.Module.Api.LocalApi.StaticFileTransmit
 
         public byte[] TransmitFile(string absFilePath)
         {
-            if (!File.Exists(absFilePath))
+            var fileInfo = new FileInfo(absFilePath);
+            if (!fileInfo.Exists)
             {
                 return SsError.Err_404.SerializeToBytes();
-            }
+            }           
 
             #region reply header
             var replyRpcData = new RpcContextData();
@@ -149,28 +171,23 @@ namespace Sers.Core.Module.Api.LocalApi.StaticFileTransmit
             {
                 rpcHeaders["Content-Type"] = contentType;             
             }
-       
-            //replyRpcData.http.headers["Cache-Control"] = "public,max-age=6000";
+    
+            rpcHeaders["Content-Length"] = fileInfo.Length.ToString();
+
+            //rpcHeaders["Cache-Control"] = "public,max-age=6000";
 
             RpcContext.Current.apiReplyMessage.rpcContextData_OriData= replyRpcData.ToBytes().BytesToArraySegmentByte();
             #endregion
 
           
             return File.ReadAllBytes(absFilePath);
+  
+        }
 
-            //Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(responseFileName, Encoding.UTF8));
-            //Response.AddHeader("Content-Length", new FileInfo(filePath).Length.ToString());
-            //Response.ContentType = (ContentType ?? MimeMapping(Path.GetExtension(responseFileName)));
-            //Response.ContentEncoding = Encoding.UTF8;
-            //Response.Charset = "utf-8";
-
-            // https://www.cnblogs.com/lonelyxmas/p/12441606.html
-            // https://www.cnblogs.com/Leo_wl/p/6059349.html
+        #endregion
 
-            //ctx.Context.Response.Headers.Append("Cache-Control", "public,max-age=600");
-            //(小知识: max - age:表示当访问此网页后的max - age秒内再次访问不会去服务器请求,其功能与Expires类似,只是Expires是根据某个特定日期值做比较。一但缓存者自身的时间不准确.则结果可能就是错误的,而max - age,显然无此问题.。Max - age的优先级也是高于Expires的。)
-        }
 
+  
 
 
 
@@ -192,8 +209,8 @@ namespace Sers.Core.Module.Api.LocalApi.StaticFileTransmit
 
         public static byte[] DownloadFile(string absFilePath, string contentType, string fileName = null)
         {
-            var info = new FileInfo(absFilePath);
-            if (!info.Exists)
+            var fileInfo = new FileInfo(absFilePath);
+            if (!fileInfo.Exists)
             {
                 return SsError.Err_404.SerializeToBytes();
             }
@@ -215,7 +232,7 @@ namespace Sers.Core.Module.Api.LocalApi.StaticFileTransmit
 
             #region 填充文件头
             headers["Content-Disposition"] = "attachment;filename=" + HttpUtility.UrlEncode(fileName, Vit.Core.Module.Serialization.Serialization_Newtonsoft.Instance.encoding);
-            headers["Content-Length"] = info.Length.ToString();
+            headers["Content-Length"] = fileInfo.Length.ToString();
             #endregion
   
 
@@ -225,11 +242,6 @@ namespace Sers.Core.Module.Api.LocalApi.StaticFileTransmit
 
             return File.ReadAllBytes(absFilePath);
 
-            //Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(responseFileName, Encoding.UTF8));
-            //Response.AddHeader("Content-Length", new FileInfo(filePath).Length.ToString());
-            //Response.ContentType = (ContentType ?? MimeMapping(Path.GetExtension(responseFileName)));
-            //Response.ContentEncoding = Encoding.UTF8;
-            //Response.Charset = "utf-8";
         }
         #endregion
 

+ 8 - 0
dotnet/ServiceCenter/App.Gover.Gateway/appsettings.json

@@ -19,6 +19,14 @@
           /* 服务端 监听端口号。例如: 4501 */
           "port": 4501,
 
+
+          /* 请求超时时间(单位ms,默认300000) */
+          "requestTimeoutMs": 300000,
+
+          /* 后台处理消息的线程个数(单位个,默认2) */
+          "workThreadCount": 2,
+
+
           //HeartBeat
           /* 心跳检测时间间隔(单位ms,默认10000,若指定为0则不进行心跳检测) */
           "heartBeatIntervalMs": 10000,

+ 2 - 3
dotnet/ServiceCenter/App.ServiceCenter/appsettings.json

@@ -1,13 +1,12 @@
 {
-
   "Sers": {
     /* 通讯层配置 */
     "CL": {
       /* 共用配置,子项共用,覆写子项未指定的配置 */
       "Config": {
 
-        /* 请求超时时间(单位ms,默认60000) */
-        "requestTimeoutMs": 60000,
+        /* 请求超时时间(单位ms,默认300000) */
+        "requestTimeoutMs": 300000,
 
         /* 后台处理消息的线程个数(单位个,默认2) */
         "workThreadCount": 2,

+ 2 - 2
dotnet/ServiceStation/Demo/SersLoader/Did.SersLoader.Demo/appsettings.json

@@ -6,8 +6,8 @@
       /* 共用配置,子项共用,覆写子项未指定的配置 */
       "Config": {
 
-        /* 请求超时时间(单位ms,默认60000) */
-        "requestTimeoutMs": 60000,
+        /* 请求超时时间(单位ms,默认300000) */
+        "requestTimeoutMs": 300000,
 
         /* 后台处理消息的线程个数(单位个,默认2) */
         "workThreadCount": 2,

+ 4 - 3
dotnet/ServiceStation/Demo/StressTest/App.Robot.Station/appsettings.json

@@ -4,12 +4,13 @@
     "CL": {
       /* 共用配置,子项共用,覆写子项未指定的配置 */
       "Config": {
+
+        /* 请求超时时间(单位ms,默认300000) */
+        "requestTimeoutMs": 300000,
+
         /* 后台处理消息的线程个数(单位个,默认2) */
         "workThreadCount": 2,
 
-        /* 请求超时时间(单位ms,默认60000) */
-        "requestTimeoutMs": 60000,
-
         /* 数据传输 加密协议,可多个,可不指定 */
         "//security": [
           {