MailChimp.Net icon indicating copy to clipboard operation
MailChimp.Net copied to clipboard

Campaigns.UpdateAsync fails due to ExpectContinue

Open lynx44 opened this issue 2 years ago • 5 comments

Today we started running into an issue where a call to Campaigns.UpdateAsync fails (the thread times out) because of the Expect header.

The MailChimpHttpClient class sets this header on every PATCH request. I was only able to work around it by removing this header inside the SendAsync method. The other .NET options to disable it didn't work since it was explicitly set on sending the message within this class.

Is this still needed? If so, can there be an option to disable it? I'm happy to submit a pull request, but I'm unsure what approach would best fit the library.

lynx44 avatar Jun 28 '22 05:06 lynx44

@lynx44 Do you mean you modified a local copy of the MailChimp.Net library? Or is there another way?

I've just run into this issue on a production service and need to resolve this quickly..

p7ac avatar Jun 28 '22 10:06 p7ac

Just want to mention that I am experiencing the same problem with every PATCH request to the Mailchimp API. Every PATCH request is unsuccessful (timeout). When I manually switch the ExpectContinue to false the request is successful. If I leave the header null the request times out.

freepay-gateway avatar Jun 28 '22 13:06 freepay-gateway

I am experiencing the exact same issue with patch request, returning timeout. I guess making it configurable would be a good option.

Do we have any good alternative, since production is down?

kosportel avatar Jun 28 '22 15:06 kosportel

@lynx44 Do you mean you modified a local copy of the MailChimp.Net library? Or is there another way?

I've just run into this issue on a production service and need to resolve this quickly..

Yes, that is correct.

My changes can be found in this fork.

I packed and deployed a prerelease version to a local filesystem repository with these commands:

nuget pack MailChimp.Net.nuspec
nuget add MailChimp.Net.V3.5.3.2.1-pnwte.nupkg -source C:\nugetpackages

Add your local package repository to the package sources in VS. If needed, replace the the .nupkg file with your package name, which is based on the version specified in the nuspec file. Click the "show prerelease" checkbox in the nuget package explorer, and select your local repo from the drop down.

Also note that I removed support to .NET 4.5 since it's unsupported in VS 2022, and I didn't need it for my project.

lynx44 avatar Jun 28 '22 17:06 lynx44

@lynx44 Do you mean you modified a local copy of the MailChimp.Net library? Or is there another way? I've just run into this issue on a production service and need to resolve this quickly..

Yes, that is correct.

My changes can be found in this fork.

I packed and deployed a prerelease version to a local filesystem repository with these commands:

nuget pack MailChimp.Net.nuspec
nuget add MailChimp.Net.V3.5.3.2.1-pnwte.nupkg -source C:\nugetpackages

Add your local package repository to the package sources in VS. If needed, replace the the .nupkg file with your package name, which is based on the version specified in the nuspec file. Click the "show prerelease" checkbox in the nuget package explorer, and select your local repo from the drop down.

Also note that I removed support to .NET 4.5 since it's unsupported in VS 2022, and I didn't need it for my project.

Thanks for this

This fix worked for me but I am still restricted with working in .NET 452, any chance this framework could be left in there for when this gets added for the next release please?

Would anyone know if and when this fix will applied into a release NuGet package by any chance?

jsmyth02 avatar Jul 08 '22 12:07 jsmyth02

Stale issue message

github-actions[bot] avatar Sep 06 '22 13:09 github-actions[bot]

I would like to reopen this issue. I started to face the same problem running mailChimpManager.Campaigns.UpdateAsync(). Digging into sources helped me to understand that the issue is due to this line https://github.com/brandonseydel/MailChimp.Net/blob/603ad4467902dbddefadd82b779bcca5854b3eaf/MailChimp.Net/Core/MailChimpHttpClient.cs#L175

            if (method.Method == "PATCH")
            {
                request.Headers.ExpectContinue = true;
            }

if I remove it, everything works just fine.

I tried it with postman and same result - without Expect: 100-continue header API call works fine: image

and with it, it hangs: image

I don't use any other PATCH method from the API but I can see there is a lot of them in the code. So I can't really submit a patch to remove this code - and clearly it was working! Looking at the campaigns logs, I can see that last successful email was sent on June 22nd, and the next one of Jul 12th was NOT sent. Which correlates well with the date provided by original posting. And I send using API call only.

avs099 avatar Sep 14 '22 00:09 avs099

I was able to "fix" this issue, by going back to a version 4.2.1

If I debug the code, I can confirm that the ExpectContinue options should not be set - at least not when updating campaigns.

soreng avatar Mar 22 '23 12:03 soreng