Results 1 to 11 of 11

Thread: TCP Provider: The specified network name is no longer available

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2018
    Location
    Krähental
    Posts
    56

    TCP Provider: The specified network name is no longer available

    I have around 250 users running this app daily for many years. Never had this problem before.

    It now ONLY affects ONE user. So I'm (reasonably (slightly?)) confident that it's not an actual bug in the code - although I do agree that I really do need to handle the error better than I do currently.

    I suppose I could just say that this one user has a duff computer or duff network connection but I also need to think that maybe the user has some windows update or other product on his computer that others have not yet installed and that, given time, others might start failing too. So I'd like to get to the bottom of it even though it's possibly not my fault (except for the bad error handling in that I hate it when a user gets an unhandled exception)

    So here goes.

    One task in the application reads a value from the database. If that succeeds it begins a transaction. Updates 3 tables and commits or rolls back. Pretty simple stuff. It goes like this:-

    Code:
    OPEN the connection.
    
    SELECT a Record ID from the database. We use ExecuteScalar to get the result from the SELECT. Not a DataReader)
    This SELECT also confirms that the connection (if drawn from the pool) is actually a working connection. This SELECT never fails.
    
    BEGIN TRANSACTION
    
    UPDATE Table_1
    UPDATE Table_2
    UPDATE Table_3
    
    COMMIT TRANSACTION
    
    CLOSE the connection

    But somewhere probably at the COMMIT point it crashes. The transaction is inside a try/catch. Inside the catch we ROLLBACK. The error is probably been thrown inside the catch

    A transport-level error has occurred when receiving results from the server. (provider: TCP Provider, error: 0 - The specified network name is no longer available.

    It's as if the server machine has disappeared. I thought perhaps the pooling was supplying a duff connection - even though the SELECT before the transaction always works.

    I've added the exception text below.

    ************** Exception Text **************
    System.Data.SqlClient.SqlException (0x80131904): A transport-level error has occurred when receiving results from the server. (provider: TCP Provider, error: 0 - The specified network name is no longer available.) ---> System.ComponentModel.Win32Exception (0x80004005): The specified network name is no longer available
    at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
    at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
    at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
    at System.Data.SqlClient.TdsParserStateObject.ReadSniError(TdsParserStateObject stateObj, UInt32 error)
    at System.Data.SqlClient.TdsParserStateObject.ReadSniSyncOverAsync()
    at System.Data.SqlClient.TdsParserStateObject.TryReadNetworkPacket()
    at System.Data.SqlClient.TdsParserStateObject.TryPrepareBuffer()
    at System.Data.SqlClient.TdsParserStateObject.TryReadByte(Byte& value)
    at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
    at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
    at System.Data.SqlClient.TdsParser.TdsExecuteTransactionManagerRequest(Byte[] buffer, TransactionManagerRequestType request, String transactionName, TransactionManagerIsolationLevel isoLevel, Int32 timeout, SqlInternalTransaction transaction, TdsParserStateObject stateObj, Boolean isDelegateControlRequest)
    at System.Data.SqlClient.SqlInternalConnectionTds.ExecuteTransactionYukon(TransactionRequest transactionRequest, String transactionName, IsolationLevel iso, SqlInternalTransaction internalTransaction, Boolean isDelegateControlRequest)
    at System.Data.SqlClient.SqlInternalConnectionTds.ExecuteTransaction(TransactionRequest transactionRequest, String name, IsolationLevel iso, SqlInternalTransaction internalTransaction, Boolean isDelegateControlRequest)
    at System.Data.SqlClient.SqlInternalConnection.BeginSqlTransaction(IsolationLevel iso, String transactionName, Boolean shouldReconnect)
    at System.Data.SqlClient.SqlConnection.BeginTransaction(IsolationLevel iso, String transactionName)
    at System.Data.SqlClient.SqlConnection.BeginDbTransaction(IsolationLevel isolationLevel)
    at System.Data.Common.DbConnection.BeginTransaction()
    at  .(Object , EventArgs )
    at System.Windows.Forms.Control.OnClick(EventArgs e)
    at System.Windows.Forms.Button.OnClick(EventArgs e)
    at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
    at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
    at System.Windows.Forms.Control.WndProc(Message& m)
    at System.Windows.Forms.ButtonBase.WndProc(Message& m)
    at System.Windows.Forms.Button.WndProc(Message& m)
    at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
    at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
    at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
    ClientConnectionId:d06895a2-6277-4925-8049-59977b742688
    Error Number:64,State:0,Class:20

  2. #2
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    11,066

    Re: TCP Provider: The specified network name is no longer available

    Looking at your error, it appears it is actually happening on the BeginTransaction request.

    However, every time I have experienced The specified network name is no longer available it is because I am having network issues on my machine and not the server.
    "Code is like humor. When you have to explain it, it’s bad." - Cory House
    VbLessons | Code Tags | Sword of Fury - Jameram

  3. #3
    PowerPoster jdc2000's Avatar
    Join Date
    Oct 2001
    Location
    Idaho Falls, Idaho USA
    Posts
    2,125

    Re: TCP Provider: The specified network name is no longer available

    I agree with dday9, that sounds like a network issue with the client computer. How is that computer connected to the network? Wired or wireless? When you get the error, can you access any network resources using other methods (shared folders, printers, etc.)?

  4. #4

    Thread Starter
    Member
    Join Date
    Jun 2018
    Location
    Krähental
    Posts
    56

    Re: TCP Provider: The specified network name is no longer available

    Quote Originally Posted by jdc2000 View Post
    I agree with dday9, that sounds like a network issue with the client computer. How is that computer connected to the network? Wired or wireless? When you get the error, can you access any network resources using other methods (shared folders, printers, etc.)?
    The computer can run the application and do any other reads and writes without error. But if it runs that one task that updates the 3 tables inside a transaction it crashes.

    As a test I started a second instance of the same application on the same computer and as soon as the error occurred I switched to the other session and ran some other process such as selecting a 1000 rows and writing some of them back to the server and that succeeds every time. So the network appears to be fine.

    And it's always just that one task. Doing anything else within the app is fine. If it was an intermittent network failure it would happen at other places within the app.

    Also want to remind you that there's 250 other people - some on the same LAN as the server and some connecting in remotely. None of them have this problem.

  5. #5
    PowerPoster jdc2000's Avatar
    Join Date
    Oct 2001
    Location
    Idaho Falls, Idaho USA
    Posts
    2,125

    Re: TCP Provider: The specified network name is no longer available

    That narrows it down to that one 3-step process. It is strange that it only occurs on one workstation though. The only other idea I had might be that the process is taking too long and timing out, causing the error.

    Possibly useful link:

    https://dba.stackexchange.com/questi...nger-available

  6. #6

    Thread Starter
    Member
    Join Date
    Jun 2018
    Location
    Krähental
    Posts
    56

    Re: TCP Provider: The specified network name is no longer available

    Quote Originally Posted by jdc2000 View Post
    That narrows it down to that one 3-step process. It is strange that it only occurs on one workstation though. The only other idea I had might be that the process is taking too long and timing out, causing the error.

    The user keys some data into a form and clicks a Save button. The error is thrown instantly. The code is pretty quick. So I don't think it could be a timeout.


    My problem is that I can't reproduce the error on my own desktop so can't debug it.

    Can anyone give me suggestions how I might be able to reproduce a "Network name no longer available" error.

    I think tomorrow I'll setup two Machines one with the client in the IDE/Debugger and other machine with SQL Server. Then single step through the code and mid way through switch off the network on the server machine. That won't fix the problem but it'll allow me to make a good error handler with an automatic retry and, failing that, report the line on which the error actually occurs in the field.

    or something like that.

    All suggestions greatly appreciated.

  7. #7
    PowerPoster jdc2000's Avatar
    Join Date
    Oct 2001
    Location
    Idaho Falls, Idaho USA
    Posts
    2,125

    Re: TCP Provider: The specified network name is no longer available

    If the error appears almost immediately, the only other thing that comes to mind would be a missing software component somewhere on the client computer, maybe a Windows component that has gone missing, is corrupted, failed to update or has an out-of-date version, or something else similar to this.

  8. #8
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    11,066

    Re: TCP Provider: The specified network name is no longer available

    Yeah, I was thinking this same thing. It might be worth doing a repair installation.
    "Code is like humor. When you have to explain it, it’s bad." - Cory House
    VbLessons | Code Tags | Sword of Fury - Jameram

  9. #9

    Thread Starter
    Member
    Join Date
    Jun 2018
    Location
    Krähental
    Posts
    56

    Re: TCP Provider: The specified network name is no longer available

    Sorry to pop this back to the top. But I just have more information from the people at the site where SQL Server is located.

    They recently upgraded all the network and telephone system on their site and, they think, this one remote user started having problems around that time.

    The problem only occurs when the client application does an explicit BeginTransaction. All read/writes outside of an explicit transaction work fine.

    In an attempt to reproduce the error on my test bed I've tried various things such as allowing the client to Open a connection and then stopping sql server or closing the network adapter on the server or switching off the network at the server site or client site and this always results in a long delay followed by a Timeout error.

    The actual problem that I can't reproduce though is an immediate error "Network Name no longer available" as soon as the client application hits the BeginTransaction. There's no timeout. It's instant.

    I'm wondering if the upgraded network/system at the server site is just a coincidence. Or is there something possible going on at the server site such as over zealous DDOS protection that's killing the connection in a way that doesn't cause a timeout. But if that were the case. Why only when the client does BeginTransaction.

    Anyway. I've added a auto-retry mechanism to the code and will deploy that on the one site next week.

    in the meantime. If anyone has any ideas please let me know. Thanks

  10. #10
    PowerPoster jdc2000's Avatar
    Join Date
    Oct 2001
    Location
    Idaho Falls, Idaho USA
    Posts
    2,125

    Re: TCP Provider: The specified network name is no longer available

    Another shot in the dark would be to check the SQL Server permissions being used by that user, in case there is a problem of some sort there. An instant error message with no timeout is a red flag that something strange is happening. You could also try using the same computer where the issue is happening, but log in to a different user account on that computer.

  11. #11

    Thread Starter
    Member
    Join Date
    Jun 2018
    Location
    Krähental
    Posts
    56

    Re: TCP Provider: The specified network name is no longer available

    Quote Originally Posted by jdc2000 View Post
    Another shot in the dark would be to check the SQL Server permissions being used by that user, in case there is a problem of some sort there. An instant error message with no timeout is a red flag that something strange is happening. You could also try using the same computer where the issue is happening, but log in to a different user account on that computer.
    Hope you guys don't mind me resurrecting this.
    Turns out it's that user's location. Something on that user's network seems to be dropping the connection.
    Yesterday I travelled to that location and using a new laptop with nothing but VStudio and the application the problem happens on my laptop too. (So nothing to do with the use's machine)

    Anyway. I tried a few things editing the source but, in the end before BEGIN TRANSACTION I close the connection and open a new one. Works 100% of the time. New code look like this.

    Code:
    OPEN the connection.
    
    SELECT a Record ID from the database. We use ExecuteScalar to get the result from the SELECT. Not a DataReader)
    This SELECT also confirms that the connection (if drawn from the pool) is actually a working connection. This SELECT never fails.
    
    
    CLOSE CONNECTION
    OPEN CONNECTION
    
    BEGIN TRANSACTION
    
    UPDATE Table_1
    UPDATE Table_2
    UPDATE Table_3
    
    COMMIT TRANSACTION
    
    CLOSE the connection

    It's as if, only on this site, the original connection becomes dirty/corrupt after executescalar and needs to be closed so that the transaction can be started with a fresh connection. (also pooling is disabled so, I assume, close and open connection really does get a brand new connection.)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width