Tuesday, June 30, 2009

How to fix WCF Error The remote server returned an unexpected response: (417) Expectation failed.

Few day’s ago one of our project(using wpf and wcf ) going live and we are start getting lots of weird error one of is 417 the remote server return unexpected response.

after some investigation and we found its only occur when client are behind a proxy in our case its squid(http://www.squid-cache.org/) and has a configuration like following in squid.conf

#This option makes Squid ignore any Expect: 100-continue header present
#in the request. Note: Enabling this is a HTTP protocol violation, but some #client may not handle it well..

#Default:
ignore_expect_100 off

we are solving this problem can be solved by changing squid configuration    

ignore_expect_100 on

the following settings on the app.config also solved the problem 

<configuration>

<system.net>

<settings>

<servicePointManager expect100Continue="false" />

</settings>

</system.net>

</configuration>

but if you have control over your proxy server settings change that. if you do not have chance to change proxy settings and handle this with changing app.config may be facing problem upload large amount of file

for more information you can check this

http://msdn.microsoft.com/en-us/library/system.net.servicepointmanager.expect100continue.aspx

2 comments:

jemmitch said...

A quick thanks for solving two days of banging my head getting a wcf service to work with an external soap based service. This solved an issue with getting http 100 back in the response and WCF throwing an exception.

Think beyond your imagination said...

Thanks a lot Nahid, I was struggling with this exception since couple of days and you made my day.