Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix RPCServer configuration falure #217

19 changes: 18 additions & 1 deletion src/RpcServer/RpcServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.ResponseCompression;
using Microsoft.AspNetCore.Server.Kestrel.Https;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Neo.IO;
using Neo.IO.Json;
Expand All @@ -15,6 +16,7 @@
using System.Reflection;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace Neo.Plugins
Expand Down Expand Up @@ -55,7 +57,22 @@ private bool CheckAuth(HttpContext context)

protected override void Configure()
{
Settings.Load(GetConfiguration());
IConfigurationSection config = null;
int remainingTimes = 3;
while (remainingTimes > 0 && config == null)
{
try
{
config = GetConfiguration();
}
catch (FormatException)
{
remainingTimes--;
Thread.Sleep(10);
}
}
erikzhang marked this conversation as resolved.
Show resolved Hide resolved
if (config == null) throw new FormatException();
Settings.Load(config);
}

private static JObject CreateErrorResponse(JObject id, int code, string message, JObject data = null)
Expand Down