Click here to Skip to main content
15,867,453 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Greetings
I´m working on an wcf service to be hosted in an IIS 8.0 the service look like:

Interface:
C#
namespace MCDWebService
{
    [ServiceContract]
    public interface IMCDService
    {
        [OperationContract]
        Respuesta CapturarHuellas(string serialDispositivo);
                
    }

    [DataContract]
    public class Respuesta
    {
        [DataMember]
        public string Codigo { get; set; }

        [DataMember]
        public Parametro Parametros { get; set; }

        [DataMember]
        public string Mensaje { get; set; }

        public Respuesta(string codigo, Parametro datos)
        {
            Codigo = codigo;
            Parametros = datos;
        }

        public Respuesta(string codigo, string mensaje)
        {
            Codigo = codigo;
            Mensaje = mensaje;
        }

    }
}

the idea is that the method "CapturarHuellas" connect asyc to a socket server and wait for the response event, it look like this:
C#
namespace MCDWebService
{
    [ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple, InstanceContextMode = InstanceContextMode.PerCall ) ]
    public class MCDService : IMCDService
    {
        private SolicitudMCD solicitudMCD;
        private System.Threading.EventWaitHandle eventoSocket;
        private Respuesta respuesta;

        
        public Respuesta CapturarHuellas(string serialDispositivo)
        {
            try
            {
                eventoSocket = new System.Threading.EventWaitHandle(true, System.Threading.EventResetMode.AutoReset);
                solicitudMCD = new SolicitudMCD(IPAddress.Parse(ConfigurationManager.AppSettings.Get("IP_MCD")),
                    int.Parse(ConfigurationManager.AppSettings.Get("Puerto_MCD")), serialDispositivo);
                solicitudMCD.Mensaje += solicitudMCD_Mensaje;

                eventoSocket.Reset();

                solicitudMCD.Solicitar();

                if (eventoSocket.WaitOne(50000)) // here wait the average waiting time is 10 seconds
                {
                    return respuesta;
                }
                else
                {
                    return new Respuesta("MCD_003_010", "Se alcanzó el tiempo máximo de respuesta del MCD.");
                }
            }
            catch (Exception ex)
            {
                return new Respuesta("MCD_003_000", ex.Message);
            }
            finally
            {
                eventoSocket.Dispose();
                solicitudMCD = null;
            }
        }

        void solicitudMCD_Mensaje(object sender, MensajeEventArgs e)
        {
            respuesta = new Respuesta(e.Codigo, e.Template);
            eventoSocket.Set();
        }
    }
}

when I use this service on localhost and the client is also in localhost it has a concurrency of 100% answered requests, but when I take the service to a new machine with the same hardware the concurrency effectiveness drops to 19% answered requests :'( .
I don´t know if its something of the service or a configuration in the IIS.

Thanks
Drugdu
Posted

1 solution

XML
the problem was not in the server was in the client you must add the following code in the app.config

<system.net>
   <connectionManagement>
      <clear/>
        <add address="*" maxconnection="1000" />
   </connectionManagement>
</system.net>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900