protected override void Opening(ServiceHost serviceHost)
        {
            foreach (var endpoint in serviceHost.Description.Endpoints)
            {
                WcfBindingUtils.ConfigureQuotas(endpoint.Binding, quotaSize);
            }

            var defaultServiceHost = serviceHost as DefaultServiceHost;

            if (defaultServiceHost != null)
            {
                defaultServiceHost.EndpointCreated += (_, newEndpoint) => WcfBindingUtils.ConfigureQuotas(newEndpoint.Endpoint.Binding, quotaSize);
            }
        }
Exemple #2
0
        private FindResponse PerformEndpointSearch(Type contract, DiscoveredEndpointModel model)
        {
            var criteria = CreateSearchCriteria(contract, model);

            for (int i = 0; i < 2; ++i)
            {
                var discoveryEndpoint = GetDiscoveryEndpoint(model);
                WcfBindingUtils.ConfigureQuotas(discoveryEndpoint.Binding, int.MaxValue);
                var discoveryClient = new DiscoveryClient(discoveryEndpoint);

                try
                {
                    return(discoveryClient.Find(criteria));
                }
                catch
                {
                    // ignore failures
                }
                finally
                {
                    try
                    {
                        discoveryClient.Close();
                    }
                    catch
                    {
                        // Discovery client often fails on close
                    }
                }

                // Possible stale discovery proxy...

                if (i == 0)
                {
                    var discoveryEndpointFaulted = DiscoveryEndpointFaulted;
                    if (discoveryEndpointFaulted != null)
                    {
                        discoveryEndpointFaulted(this, new DiscoveryEndpointFaultEventArgs(discoveryEndpoint));
                    }
                }
            }

            return(null);
        }
 public override void Opening(ChannelFactory channelFactory)
 {
     WcfBindingUtils.ConfigureQuotas(channelFactory.Endpoint.Binding, quotaSize);
 }