我如何在Iss 8.0的等待过程中获得并发? [英] How I Make Concurrence In A Wait Process Wcf On Iss 8.0?

查看:68
本文介绍了我如何在Iss 8.0的等待过程中获得并发?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问候

我正在开发一个在IIS 8.0中托管的wcf服务,服务外观如下:



界面:

Greetings
I´m working on an wcf service to be hosted in an IIS 8.0 the service look like:

Interface:

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;
        }

    }
}



的想法是CapturarHuellas方法将asyc连接到套接字服务器并且等待响应事件,它看起来像这样:


the idea is that the method "CapturarHuellas" connect asyc to a socket server and wait for the response event, it look like this:

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();
        }
    }
}



当我在localhost上使用此服务而客户端也在localhost时它的并发性为100 %回答了请求,但是当我将服务带到具有相同硬件的新机器时,并发效率降至19%回答请求:'(。

我不知道它是否有什么服务或IIS中的配置。



谢谢

Drugdu


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

推荐答案

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>


这篇关于我如何在Iss 8.0的等待过程中获得并发?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆