oocx / acme.net

A .net implementation of ACME (Automatic Certificate Management Environment)
MIT License
89 stars 19 forks source link

Hang in Parsing response #3

Closed Bobris closed 8 years ago

Bobris commented 8 years ago

Don't know why but it hangs on first Directory response and this fix makes it work:

 src/Oocx.ACME/Client/AcmeClient.cs | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

 diff --git a/src/Oocx.ACME/Client/AcmeClient.cs b/src/Oocx.ACME/Client/AcmeClient.cs 
 index 76fb7c9..832909e 100644
--- a/src/Oocx.ACME/Client/AcmeClient.cs
+++ b/src/Oocx.ACME/Client/AcmeClient.cs
@@ -213,7 +213,8 @@ namespace Oocx.ACME.Client
                 return certificateResponse as TResult;
             }

-            var responseContent = await response.Content.ReadAsAsync<TResult>();
+            var responseJson = await response.Content.ReadAsStringAsync();
+            var responseContent = JsonConvert.DeserializeObject<TResult>(responseJson);

             GetHeaderValues(response, responseContent);
Bobris commented 8 years ago

Hi, will you accept pull request, because this is only thing which currently blocks me to publish Nowin middleware.

oocx commented 8 years ago

I'd like to reproduce the error first before I fix anything that I don't understand. What exactly are you doing to cause this call to hang? How are you calling this code? Which runtime are you using?

oocx commented 8 years ago

I added ConfigureAwait(false) to async calls in AcmeClient. Depending on how you use the client, deadlocks may occur without ConfigureAwait(false). However, now calls to AcmeClient might return on a different thread than the one used to call its methods. Please try 0.0.0-beta-75 to see if this fixes your problem.

Bobris commented 8 years ago

Yes, that's was problem. I can confirm 0.0.0-beta-75 works without problem.