Fix WCF AddressFilter mismatch error when hosted behind load balancer

Weeks ago we had an issue with WCF web service hosted behind a load balancer that does address redirection and SSL handling. The error message is

“The message with To ‘https://Your/WCF/Service.svc ‘ cannot be processed at the receiver, due to an AddressFilter mismatch at the EndpointDispatcher.  Check that the sender and receiver’s EndpointAddresses agree.”

Basically this means that your WCF service hosted behind the load balancer does not recognize the request, because the request’s “TO” address, which is a public facing address pointing to the load balancer, does not match the EndpointAddress of your WCF service, which comes from the IIS base address/host headers on the actual web server (where the load balancer will eventually redirect the request)

This checking mechanism of WCF is called AddressFilter, which is default to be turned on. So to fix the issue, add this line of code above each service to turn it off:


[ServiceBehavior(AddressFilterMode=AddressFilterMode.Any)]

This is a quick and easy fix, but if you have a big number of services, creating a custom behavior to change the default AddressFilter is more feasible. Check the first link in the reference for detail of how to do that.

References:

Fix WCF AddressFilter mismatch error, customized IServiceBehavior , WCF service behind Load balancer or Firewall

Address Filter mismatch – WCF addressing

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s