MetacoSA / QBitNinja

An Open Source and powerful blockchain API
MIT License
68 stars 42 forks source link

Microsoft.WindowsAzure.Storage.StorageException: The remote server returned an error: (400) Bad Request #97

Closed kepikoi closed 5 years ago

kepikoi commented 5 years ago

I followed the steps with Visual Studio 2019 on a Win10 Pro 1809 B4ms VM and compiled to RELEASE. Still I'm getting this exception on init:

PS C:\Users\Fe\QBitNinja\QBitNinja.Listener.Console\bin\Release\net471> .\QBitNinja.Listener.Console.exe --init

Unhandled Exception: System.AggregateException: One or more errors occurred. ---> Microsoft.WindowsAzure.Storage.StorageException: The remote server returned an error: (400) Bad Request. ---> System.Net.WebException: The remote server returned an error: (400) Bad Request.
   at Microsoft.WindowsAzure.Storage.Table.Protocol.TableOperationHttpResponseParsers.TableOperationPreProcess(TableResult result, TableOperation operation, HttpWebResponse resp, Exception ex)
   at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.EndGetResponse[T](IAsyncResult getResponseResult)
   --- End of inner exception stack trace ---
   at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.EndExecuteAsync[T](IAsyncResult result)
   at Microsoft.WindowsAzure.Storage.Table.CloudTable.EndCreateIfNotExists(IAsyncResult asyncResult)
   at Microsoft.WindowsAzure.Storage.Core.Util.AsyncExtensions.<>c__DisplayClass1`1.<CreateCallback>b__0(IAsyncResult ar)
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.WaitAll(Task[] tasks, Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at QBitNinja.QBitNinjaConfiguration.EnsureSetup() in C:\Users\Bulma\QBitNinja\QBitNinja\QBitNinjaConfiguration.cs:line 222
   at QBitNinja.Listener.Console.Program.Main(String[] args)

I've set up azure like described in readme although I had to make own assumptions on specific configurations of the azure services (e.g. using azure storage standard and NOT the premium tier). I configured QBitNinja.Listener-Console\App.config with the primary key of my storage account (settings redacted)

...
<appSettings>
    <add key="Azure.AccountName" value="samplestoragename" />
    <add key="Azure.Key" value="longprimarystoragekey==" />
    <add key="Network" value="mainnet" />
    <add key="Chain" value="BTC" />
    <add key="Node" value="" />
    <add key="RPCConnectionString" value="server=http://127.0.0.1:8332;rpcuser:rpcpw="/>
    <add key="ServiceBus" value="Endpoint=sb://samplename.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=somekey=" />
    <add key="StorageNamespace" value="" />
    <add key="CheckpointSetName" value="" />
  </appSettings>
...

My bitcoind is fully synced to the 1TB disk mounted to E:. The rpc interface is protected via the rpcauth setting

Due to some incompatibility issues with VS2019 I had to modify the contents of global.json to:

{
  "sdk": {
    "version": "2.1.400"
  }
}

My dotnet info:


PS C:\Users\Fe\QBitNinja\QBitNinja.Listener.Console\bin\Debug\net471> dotnet --info
.NET Core SDK (reflecting any global.json):
 Version:   2.1.400
 Commit:    8642e60a0f

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.17763
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\2.1.400\

Host (useful for support):
  Version: 2.2.5
  Commit:  0a3c9209c0

.NET Core SDKs installed:
  2.1.400 [C:\Program Files\dotnet\sdk]
  2.1.700 [C:\Program Files\dotnet\sdk]
  2.2.300 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download

I've tried to run the testsuite but quite a lot of the test fail for some reason :

[6/6/2019 11:21:39 AM Informational] ------ Discover test started ------
[6/6/2019 11:21:40 AM Warning] Test run will use DLL(s) built for framework .NETFramework,Version=v4.5 and platform X86. Following DLL(s) do not match framework/platform settings.
QBitNinja.Client.Tests.dll is built for Framework 4.7.2 and Platform AnyCPU.
QBitNinja.Listener.Console.exe is built for Framework 4.7.1 and Platform AnyCPU.
QBitNinja.Tests.dll is built for Framework 4.7.2 and Platform AnyCPU.
QBitNinja.dll is built for Framework 4.7.1 and Platform AnyCPU.
Go to http://go.microsoft.com/fwlink/?LinkID=236877&clcid=0x409 for more details on managing these settings.

[6/6/2019 11:21:41 AM Informational] [xUnit.net 00:00:00.3807924]   Discovering: QBitNinja.Client.Tests
[6/6/2019 11:21:41 AM Informational] [xUnit.net 00:00:00.4726798]   Discovered:  QBitNinja.Client.Tests
[6/6/2019 11:21:42 AM Informational] [xUnit.net 00:00:00.8652156]   Discovering: QBitNinja.Tests
[6/6/2019 11:21:42 AM Informational] [xUnit.net 00:00:00.9675576]   Discovered:  QBitNinja.Tests
[6/6/2019 11:21:43 AM Informational] ========== Discover test finished: 34 found (0:00:03.7899941) ==========
[6/6/2019 11:21:43 AM Informational] ------ Run test started ------
[6/6/2019 11:21:43 AM Warning] Test run will use DLL(s) built for framework .NETFramework,Version=v4.5 and platform X86. Following DLL(s) do not match framework/platform settings.
QBitNinja.Client.Tests.dll is built for Framework 4.7.2 and Platform AnyCPU.
QBitNinja.Tests.dll is built for Framework 4.7.2 and Platform AnyCPU.
Go to http://go.microsoft.com/fwlink/?LinkID=236877&clcid=0x409 for more details on managing these settings.

[6/6/2019 11:21:44 AM Informational] [xUnit.net 00:00:00.3745614]   Discovering: QBitNinja.Client.Tests
[6/6/2019 11:21:44 AM Informational] [xUnit.net 00:00:00.4737336]   Discovered:  QBitNinja.Client.Tests
[6/6/2019 11:21:44 AM Informational] [xUnit.net 00:00:00.4782889]   Starting:    QBitNinja.Client.Tests
[6/6/2019 11:23:25 AM Error] [xUnit.net 00:01:41.3080301]     QBitNinja.Client.Tests.Class1.CanDetectUncoherentNetwork [FAIL]
[6/6/2019 11:23:25 AM Informational] [xUnit.net 00:01:41.3090429]       System.InvalidCastException : Unable to cast object of type 'System.Threading.Tasks.TaskCanceledException' to type 'QBitNinja.Client.Models.QBitNinjaException'.
[6/6/2019 11:23:25 AM Informational] [xUnit.net 00:01:41.3096451]       Stack Trace:
[6/6/2019 11:23:25 AM Informational] [xUnit.net 00:01:41.3104163]         C:\Users\Fe\QBitNinja\QBitNinja.Client.Tests\Class1.cs(83,0): at QBitNinja.Client.Tests.Class1.CanDetectUncoherentNetwork()
[6/6/2019 11:23:43 AM Error] [xUnit.net 00:01:59.3287842]     QBitNinja.Client.Tests.Class1.CanTryBroadcast [FAIL]
[6/6/2019 11:23:43 AM Informational] [xUnit.net 00:01:59.3289487]       Assert.False() Failure
[6/6/2019 11:23:43 AM Informational] [xUnit.net 00:01:59.3290029]       Expected: False
[6/6/2019 11:23:43 AM Informational] [xUnit.net 00:01:59.3290247]       Actual:   True
[6/6/2019 11:23:43 AM Informational] [xUnit.net 00:01:59.3290933]       Stack Trace:
[6/6/2019 11:23:43 AM Informational] [xUnit.net 00:01:59.3291555]         C:\Users\Fe\QBitNinja\QBitNinja.Client.Tests\Class1.cs(66,0): at QBitNinja.Client.Tests.Class1.CanTryBroadcast()
[6/6/2019 11:23:48 AM Error] [xUnit.net 00:02:04.4818794]     QBitNinja.Client.Tests.Class1.CanManageWallet [FAIL]
[6/6/2019 11:23:48 AM Informational] [xUnit.net 00:02:04.4820239]       Assert.True() Failure
[6/6/2019 11:23:48 AM Informational] [xUnit.net 00:02:04.4820624]       Expected: True
[6/6/2019 11:23:48 AM Informational] [xUnit.net 00:02:04.4820868]       Actual:   False
[6/6/2019 11:23:48 AM Informational] [xUnit.net 00:02:04.4822454]       Stack Trace:
[6/6/2019 11:23:48 AM Informational] [xUnit.net 00:02:04.4823270]         C:\Users\Fe\QBitNinja\QBitNinja.Client.Tests\Class1.cs(106,0): at QBitNinja.Client.Tests.Class1.CanManageWallet()
[6/6/2019 11:25:28 AM Error] [xUnit.net 00:03:44.5018101]     QBitNinja.Client.Tests.Class1.CanGetTransaction [FAIL]
[6/6/2019 11:25:28 AM Informational] [xUnit.net 00:03:44.5021340]       System.AggregateException : One or more errors occurred.
[6/6/2019 11:25:28 AM Informational] [xUnit.net 00:03:44.5021807]       ---- System.Threading.Tasks.TaskCanceledException : A task was canceled.
[6/6/2019 11:25:28 AM Informational] [xUnit.net 00:03:44.5022972]       Stack Trace:
[6/6/2019 11:25:28 AM Informational] [xUnit.net 00:03:44.5023520]            at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
[6/6/2019 11:25:28 AM Informational] [xUnit.net 00:03:44.5024188]            at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
[6/6/2019 11:25:28 AM Informational] [xUnit.net 00:03:44.5024692]            at System.Threading.Tasks.Task`1.get_Result()
[6/6/2019 11:25:28 AM Informational] [xUnit.net 00:03:44.5025478]         C:\Users\Fe\QBitNinja\QBitNinja.Client.Tests\Class1.cs(148,0): at QBitNinja.Client.Tests.Class1.CanGetTransaction()
[6/6/2019 11:25:28 AM Informational] [xUnit.net 00:03:44.5026208]         ----- Inner Stack Trace -----
[6/6/2019 11:25:28 AM Informational] [xUnit.net 00:03:44.5026748]         
[6/6/2019 11:25:31 AM Informational] [xUnit.net 00:03:47.6303831]   Finished:    QBitNinja.Client.Tests
[6/6/2019 11:25:31 AM Informational] [xUnit.net 00:03:47.9632878]   Discovering: QBitNinja.Tests
[6/6/2019 11:25:31 AM Informational] [xUnit.net 00:03:48.0625466]   Discovered:  QBitNinja.Tests
[6/6/2019 11:25:31 AM Informational] [xUnit.net 00:03:48.0628170]   Starting:    QBitNinja.Tests
NicolasDorier commented 5 years ago

I don't know, seems a problem in the configuration of your azure storage.

Can you check whether in C:\Users\Fe\QBitNinja\QBitNinja.Listener.Console\bin\Debug\net471\QBitNinja.Listener.Console.exe.config there is your settings? (Normally when you build, App.Config get copied to this destination)

kepikoi commented 5 years ago

Thank you, but the issue was not with the settings. After poking around in the debugger I stumbled upon this error message StatusMessage:The account being accessed does not support http. which led me to the solution referenced here: https://stackoverflow.com/questions/44528162/azure-storage-java-api-account-does-not-support-http

Apparently it is required to disable "secure transfer" in the Azure storage account image

NicolasDorier commented 5 years ago

Ah that's new, I was not aware of it. Will update the README! Glad it is solved.

NicolasDorier commented 5 years ago

I just updated the README with this info! Thanks!

timhonisett commented 3 years ago

Perfect! After several days of swearing at my PC, this has solved the issue!