The service does not respond after a while in WCF + EntityFramwork

0

I have the following service:

[OperationContract]
[WebGet(UriTemplate = "Banks", BodyStyle = WebMessageBodyStyle.WrappedRequest, ResponseFormat = WebMessageFormat.Json)]
List<BankModel> GetBanks();
public List<BankModel> GetBanks()
{
    _Bank = new BankBusiness();
    return _Bank.GetBanks();
}
public List<BankModel> GetBanks()
{
    _Bank = new BankRepository();
    return _Bank.GetBanks();
}
public List<BankModel> GetBanks()
{
    using (var ctx = new GROWEntities())
    {
        try
        {                                       
            return lista = ctx.Database.SqlQuery<Bank>("Select [id], [code],[description] From Bank").Select(MapToModel).ToList();
        }
        catch (System.Exception ex)
        {

            throw;
        }
    }
}

It turns out that it works normally, but after about 20 minutes, the service no longer responds, and doing debug, executes the line:

List<BankModel> lista = ctx.Database.SqlQuery<Bank>("Select [id], [code],[description] From Bank").Select(MapToModel).ToList(); 

And never again follows the next one.

The service is reset for a long time or after restarting the PC.

The configuration is as follows:

<services>
  <!-- Note: the service name must match the configuration name for the service implementation. -->
  <service name="Grow.Service.GrowService" behaviorConfiguration="MyServiceTypeBehaviors">
    <!-- Add the following endpoint.  -->
    <!-- Note: your service must have an http base address to add this endpoint. -->
    <endpoint contract="Grow.Service.IGrowService" binding="mexHttpBinding" address="mex" />

    <!--<endpoint address="" behaviorConfiguration="webBehavior" binding="webHttpBinding" contract="Grow.Service.IGrowService" />-->
    <endpoint address="../GrowService.svc" binding="webHttpBinding" contract="Grow.Service.IGrowService" behaviorConfiguration="webBehavior" />
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:60449/GrowService.svc" />
      </baseAddresses>
    </host>

  </service>
</services>

<behaviors>

  <endpointBehaviors>
    <behavior name="webBehavior">
      <webHttp />
    </behavior>

  </endpointBehaviors>
  <serviceBehaviors>
    <behavior name="MyServiceTypeBehaviors">
      <!-- Add the following element to your service behavior configuration. -->
      <serviceMetadata httpGetEnabled="true" />
    </behavior>
  </serviceBehaviors>
</behaviors>

<protocolMapping>
  <add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" minFreeMemoryPercentageToActivateService="0" />

                                                                                      

    
asked by Andrés Zapata 10.01.2017 в 22:06
source

0 answers