none
Error: "A transport-level error has occurred when receiving results from the server. (provider: TCP Provider, error: 0 - The semaphore timeout period has expired.)" RRS feed

  • Question

  • I have done a lot of reading on this error, but failed to find any solution for my case.  Please bear with me while I explain why I think this is related to Entity Framework.

    Originally, I kept getting the error "A transport-level error has occurred when receiving results from the server. (provider: Session Provider, error: 19 - Physical connection is not usable" every one or two days, and the only way to remedy it is rebooting the Windows 7 box. After I added  "Connection Lifetime=3;Max Pool Size=3" to the connection string, that error has never occurred again.  

    The relevant code is the following.

    using (Models.FooEntities context = new Models.FooEntities())
    {
        context.CommandTimeout = 300;
        Models.tblFoo foo = new Models.tblFoo();
        foo.DateTime = DateTime.Now;
        ...
        try
        {
            context.SaveChanges();
        }
        catch (EntityDataSourceValidationException edsve)
        {
            ...
        }
        catch (Exception ex)
        {
            //"A transport-level error has occurred when receiving results from the server. (provider: TCP Provider, error: 0 - The semaphore timeout period has expired.)"  is caught here
        }
    }


    When this happens, another web application using Entity Framework stops working too, but I do not have any control of that web application, so I do not know what exception it gets.  I suspect it is the same as the other web app using Entity Framework.

    When these two web apps using Entity Framework stop working due to the problem, the SQL Server 2012 works fine with many other applications (e.g. other web apps, desktop apps such as Microsoft Access).

    The error is supposed to be related TCP sockets. When I check  the event log, I see the Windows 7 computer has has lots of the following event:

    - System 
    
      - Provider 
    
       [ Name]  srv 
     
      - EventID 2017 
    
       [ Qualifiers]  49152 
     
       Level 2 
     
       Task 0 
     
       Keywords 0x80000000000000 
     
      - TimeCreated 
    
       [ SystemTime]  2013-11-06T19:23:46.515205200Z 
     
       EventRecordID 6685693 
     
       Channel System 
     
       Computer PHENOMVII 
     
       Security 
     
    
    - EventData 
    
       \Device\LanmanServer 
       0000040001002C0000000000E10700C0000000009A0000C00000000000000000000000000000000093020000 

    However, this event occurs all the time regardless of whether the aforementioned error is occurring. 

    I am wondering if anyone could shed some light on this. Is there a way to reset Entity Framework without restarting the computer?


    Hong


    Wednesday, November 6, 2013 8:25 PM

Answers

  • I am quite confident now to conclude that the problem has been solved by using named pipes in connection strings used by Entity Framework.

    Hong

    Wednesday, November 13, 2013 12:42 PM

All replies

  • Hello,

    >> Is there a way to reset Entity Framework without restarting the computer?

    Entity Framework is a framework not an application or .exe program. It does not have the restart conceptual. It hosts on the application, when the application restarts, the entity framework will restart.

    From the error message, we can find it comes from TCP Provider, we generally think this semaphore time-out error is caused by intermittent network failure.

    This semaphore time-out error means the server didn’t receive the response from SQL Server in time, this might be the both server have high load at the problem time.

    1. This semaphore time-out error means the server didn’t receive the response from SQL Server in time, this might be the both server have high load at the problem time.
    2. If there are others job or query to scan the same table, it might be blocked by these query.

    To solve these issues, here are some suggestions for this:

    1. Reduce the load on the SQL Server server, we could end some unnecessary program at the current time
    2. Also we could optimize this query. We could make it run faster and lock less resources by using clustered index and nonclustered index for the tables, therefore reduce the possibility of being blocked.
    3. Also try to reboot the server and execute the job manually.

    Please feel free to ask any questions.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, November 7, 2013 3:36 AM
    Moderator
  • Hi Fred,

    Thanks a lot for all the elucidation. 

    I have tried the following:

    1. Rebooting SQL Server (2012) more than once.
    2. Restarting IIS more than once (both problematic apps are web apps).
    3. Clear all pools.

    None of them work.

    I have followed a post to address the issue "The server was unable to allocate from the system nonpaged pool because the pool was empty"  by modifying registry.  It has got rid this error which shows in the event log.  I will see this helps solve this problem. 

    I will report back.  It may take two or three days.


    Hong


    Thursday, November 7, 2013 3:53 AM
  • Hi Fred,

    I forgot to mention that the server is a lightly used one most of the time.  The query is a simple insertion of a record.

    When it occurs for the first time, it could be caused by busy server, but it will keep occurring until reboot regardless of the state of the machine (the CPU usage is below 10%, and there is more than 5GB of free memory out of 12GB of the machine).

    Anyway, I will report back in one or two days.


    Hong

    Thursday, November 7, 2013 10:39 AM
  • Well, it started happening again about an hour ago.  All web apps using Entity Framework cannot serve pages.  Those web apps independent of each other, but they are hosted on the same machine and use the same SQL Server, but different databases. 

    I do not see anything special in event logs. 

    Restarting these web apps or restarting IIS does not help. 

    I restarted the machine and everything is fine now.  I expect it will remain good for the next 30 to 50 hours.


    Hong

    Friday, November 8, 2013 3:12 PM
  • It happened again.  It occurred in about 12 hours after reboot.

    Hong

    Saturday, November 9, 2013 5:00 AM
  • Is it that when the error occurs the connection pool is full or the metwork is Unstable?


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, November 11, 2013 2:05 AM
    Moderator
  • The network is extremely stable as far as I know when this error occurs because I test the network extensively when this happens.  I do Remote Desktop to the machine, access the database with Microsoft Access, access multiple shared folders of the machine from another computer, browse all sorts of web pages served by the computer.  All work perfectly.  Only the web apps using Entity Framework do not work.

    I changed the connection strings to use named pipes when this error happened last time (yesterday morning), and the problem disappeared immediately.  That was the first time I could stop the problem without rebooting the machine.  The problem has not occurred since then. 

    If everything will be fine for one or two more days, I will tend to conclude that Entity Framework does like TCP connection with a local SQL database on a Windows 7 machine. 


    Hong

    Monday, November 11, 2013 2:32 AM
  • I am quite confident now to conclude that the problem has been solved by using named pipes in connection strings used by Entity Framework.

    Hong

    Wednesday, November 13, 2013 12:42 PM
  • Oh,

    It is amazed that the connectionstring will cause this issue.

    And thanks for sharing it with us, as we know, this issue is very random and it has broken someones head.

    I think they will be thankful if they see this solution.

    Cheers.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, November 14, 2013 5:35 AM
    Moderator
  • Hi Hong,

    I have similar issue with LINQ to SQL. If one of my application server is not connecting to the database, even my SSMS from application server doesn't connect. I wonder if you had tried something similar either using SSMS or SqlCmd?

    Can you give me a sample of how you used NamedPipes in the connection string?

    Thanks

    VJ

    Tuesday, November 17, 2015 7:05 PM
  • Hello VJ,

    Sorry for the delayed response.  Here is the connection string in web.config:

        <add name="MyEntities" connectionString="metadata=res://*/App_Code.ModelMy.csdl|res://*/App_Code.ModelMy.ssdl|res://*/App_Code.ModelMy.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=np:\\MyServerComputerName\pipe\sql\query;initial catalog=My;user id=myid;password=mypassword;Connection Lifetime=3;Max Pool Size=3;App=EntityFramework&quot;" providerName="System.Data.EntityClient"/>
    


    Hong

    Friday, November 20, 2015 4:14 PM