fix rpc client error
This commit is contained in:
@@ -36,11 +36,11 @@ public partial class Synapse
|
|||||||
RpcClientChannel.BasicConsume(queue, false, "", false, false, null, consumer);
|
RpcClientChannel.BasicConsume(queue, false, "", false, false, null, consumer);
|
||||||
}
|
}
|
||||||
|
|
||||||
private object FireRpc(string app, string action, object param)
|
private string FireRpc(string app, string action, object param)
|
||||||
{
|
{
|
||||||
var paramJson = JsonSerializer.Serialize(param, SimApiUtil.JsonOption);
|
var paramJson = JsonSerializer.Serialize(param, SimApiUtil.JsonOption);
|
||||||
var router = $"server.{app}";
|
var router = $"server.{app}";
|
||||||
SimApiBaseResponse response;
|
string response;
|
||||||
var props = RpcClientChannel.CreateBasicProperties();
|
var props = RpcClientChannel.CreateBasicProperties();
|
||||||
props.AppId = Options.AppId;
|
props.AppId = Options.AppId;
|
||||||
props.MessageId = Guid.NewGuid().ToString();
|
props.MessageId = Guid.NewGuid().ToString();
|
||||||
@@ -55,13 +55,12 @@ public partial class Synapse
|
|||||||
{
|
{
|
||||||
if (SimApiUtil.TimestampNow - ts > Options.RpcTimeout)
|
if (SimApiUtil.TimestampNow - ts > Options.RpcTimeout)
|
||||||
{
|
{
|
||||||
response = new SimApiBaseResponse(502, "timeout");
|
response = JsonSerializer.Serialize(new SimApiBaseResponse(502, "timeout"), SimApiUtil.JsonOption);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (ResponseCache.TryGetValue(props.MessageId, out var value))
|
if (ResponseCache.TryGetValue(props.MessageId, out var value))
|
||||||
{
|
{
|
||||||
response = JsonSerializer.Deserialize<SimApiBaseResponse<object>>(
|
response = Encoding.UTF8.GetString(value);
|
||||||
Encoding.UTF8.GetString(value), SimApiUtil.JsonOption);
|
|
||||||
ResponseCache.Remove(props.MessageId);
|
ResponseCache.Remove(props.MessageId);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -96,7 +96,8 @@ public partial class Synapse
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
res = FireRpc(appName, method, param);
|
var data = FireRpc(appName, method, param);
|
||||||
|
res = JsonSerializer.Deserialize<SimApiBaseResponse<T>>(data, SimApiUtil.JsonOption);
|
||||||
}
|
}
|
||||||
return res as SimApiBaseResponse<T>;
|
return res as SimApiBaseResponse<T>;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user