Friday, June 08, 2012

The request failed with HTTP status 417: Expectation Failed

I helped someone to troubleshoot an annoying issue he was facing when using an Excel Add-In.

The Add-In is consuming a webservice on a remote server.  The following is the error he got when he tried to logon using the Add-In.

The request failed with HTTP status 417 Expectation Failed

He told me that he has to bypass proxy server in order to make it works.  However, if he bypass proxy server, he cannot access Internet.  So it is annoying because he needs to toggle between having proxy settings and no proxy settings.

A quick search on the Internet, reveals that the HTTP status 417 is related to the 100 continue request.  The proxy server in question is Squid 3.1 which does not forward the 100 continue request in the header and will return 417 code.  It will then expect the client to retry without the 100 continue request in the header but this client choose to display the error instead.  The following screen shots captured from Wireshark shows what is happening.

The client having the Expect: 100-continue in the request.

Expect  100-continue

The Squid proxy server returns 417 Expectation Failed.

417 Expectation Failed

When bypassing the proxy server, the server providing the webservice responded with 100 Continue.

Response 100-continue

There are three options to solve this annoying issue.

Option 1:

Add <servicePointManager expect100Continue="false" /> in the client’s configuration file to omit Expect: 100-continue from the request.

<system.net>
   <settings>
      <servicePointManager expect100Continue="false" />
   </settings>
</system.net>

With the <servicePointManager expect100Continue="false" />, the Expect: 100-continue will not appear in the request.

No Expect 100-Continue

Option 2:

Set the ignore_expect_100 in the Squid configuration file (squid.conf) to on.

ignore_expect_100 on

The default setting for ignore_expect_100 is off.  http://www.squid-cache.org/Doc/config/ignore_expect_100/ provides more information about this setting.

Option 3:

Simply allows the client to bypass the proxy server for this webservice’s URL.

Since I do not want to mess with the application configuration file so Option 2 or Option 3 will be my choice.

No comments: