richardschneider / net-ipfs-http-client

InterPlanetary File System client for .Net (C#, VB, F# ...)
MIT License
158 stars 52 forks source link

Hangs in any method #60

Closed ultranetorg closed 4 years ago

ultranetorg commented 4 years ago

Hello

I’ve the latest go-ipfs for windows and the latest Ipfs.Http.IpfsClient from Nuget Ipfs node is started using “ipfs daemon” command

Then I try to access it but nothing from the below works, Ipfs hangs in every call:

var ipfs = new IpfsClient();

var data = ipfs.FileSystem.ReadFileAsync("/ipfs/QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnPbdG/readme").Result;
var peer = ipfs.IdAsync().Result;
var cid = ipfs.FileSystem.AddTextAsync(w.ToString()).Result.Id;
ultranetorg commented 4 years ago

I've found that something is wrong with standard HttpClient cause it hangs in the highlighted line below:

        public async Task<Stream> DownloadAsync(string command, CancellationToken cancel, string arg = null, params string[] options)
        {
            var url = BuildCommand(command, arg, options);
            if (log.IsDebugEnabled)
                log.Debug("GET " + url.ToString());
HERE!!      var response = await Api().GetAsync(url, HttpCompletionOption.ResponseHeadersRead, cancel);
            await ThrowOnErrorAsync(response);
            return await response.Content.ReadAsStreamAsync();
        }

No idea why it happens... and when I open provided url in the browser I get a correct result

ultranetorg commented 4 years ago

Ok so I've found the cause We cant use .Result property of Async return. Only await