Click here to Skip to main content
15,172,951 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a win form application coded in c# 2010.
The server is in somewhere else and has a IP Valid(SQL Server 2008 enterprise edition).

When the application is idle for about 45 seconds, after a request i have the exception below.

Thanks.

-----------------------

System.Data.SqlClient.SqlException was unhandled
  Message=A transport-level error has occurred when sending the request to the server. (provider: TCP Provider, error: 0 - An existing connection was forcibly closed by the remote host.)
  Source=.Net SqlClient Data Provider
  ErrorCode=-2146232060
  Class=20
  LineNumber=0
  Number=10054
  Server=211.211.141.116
  State=0
  StackTrace:
       at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
       at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
       at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
       at System.Data.SqlClient.TdsParserStateObject.WriteSni()
       at System.Data.SqlClient.TdsParserStateObject.WritePacket(Byte flushMode)
       at System.Data.SqlClient.TdsParserStateObject.ExecuteFlush()
       at System.Data.SqlClient.TdsParser.TdsExecuteSQLBatch(String text, Int32 timeout, SqlNotificationRequest notificationRequest, TdsParserStateObject stateObj)
       at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
       at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
       at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
       at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
       at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
       at System.Data.Common.DbCommand.ExecuteReader()
       at System.Data.Linq.SqlClient.SqlProvider.Execute(Expression query, QueryInfo queryInfo, IObjectReaderFactory factory, Object[] parentArgs, Object[] userArgs, ICompiledSubQuery[] subQueries, Object lastResult)
       at System.Data.Linq.SqlClient.SqlProvider.ExecuteAll(Expression query, QueryInfo[] queryInfos, IObjectReaderFactory factory, Object[] userArguments, ICompiledSubQuery[] subQueries)
       at System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(Expression query)
       at System.Data.Linq.DataQuery`1.System.Collections.Generic.IEnumerable<t>.GetEnumerator()
       at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
       at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
       at System.Data.Linq.Provider.BindingList.Create[T](DataContext context, IEnumerable`1 sequence)
       at System.Data.Linq.DataQuery`1.GetNewBindingList()
       at System.Data.Linq.DataQuery`1.System.ComponentModel.IListSource.GetList()
       at System.Windows.Forms.ListBindingHelper.GetList(Object list)
       at System.Windows.Forms.ListBindingHelper.GetList(Object dataSource, String dataMember)
       at System.Windows.Forms.BindingSource.ResetList()
       at System.Windows.Forms.BindingSource.set_DataSource(Object value)
       at Job.frmJobExperience.LoadActionTypeTypes() in D:\Projects\Behdasht 20110709\BehdashProject\Behdasht\Job\frmJobExperience.cs:line 99
       at Job.frmJobExperience.LoadAndRefreshData() in D:\Projects\Behdasht 20110709\BehdashProject\Behdasht\Job\frmJobExperience.cs:line 63
       at Job.frmJobExperience.frmJobExperience_Load(Object sender, EventArgs e) in D:\Projects\Behdasht 20110709\BehdashProject\Behdasht\Job\frmJobExperience.cs:line 108
       at System.Windows.Forms.Form.OnLoad(EventArgs e)
       at System.Windows.Forms.Form.OnCreateControl()
       at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
       at System.Windows.Forms.Control.CreateControl()
       at System.Windows.Forms.Control.WmShowWindow(Message& m)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
       at System.Windows.Forms.ContainerControl.WndProc(Message& m)
       at System.Windows.Forms.Form.WmShowWindow(Message& m)
       at System.Windows.Forms.Form.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.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow)
       at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
       at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
       at System.Windows.Forms.Control.set_Visible(Boolean value)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.RunDialog(Form form)
       at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
       at System.Windows.Forms.Form.ShowDialog()
       at Job.frmJobInfo.cmsJobExpierence_Click(Object sender, CommandEventArgs e) in D:\Projects\Behdasht 20110709\BehdashProject\Behdasht\Job\frmJobInfo.cs:line 1389
       at Janus.Windows.UI.CommandBars.CommandEventHandler.Invoke(Object sender, CommandEventArgs e)
       at Janus.Windows.UI.CommandBars.UICommand.OnClick(CommandEventArgs e)
       at Janus.Windows.UI.CommandBars.UICommand.at()
       at Janus.Windows.UI.Internal.JNSY.OnMouseUp(MouseEventArgs e)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at Janus.Windows.UI.Internal.JNSY.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.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at Janus.Windows.UI.JNSCQ.b(b& )
       at Janus.Windows.UI.Internal.JNSY.k()
       at Janus.Windows.UI.Internal.JNSY.b(Point )
       at Janus.Windows.UI.CommandBars.UIContextMenu.a(Control , Point , Int32 )
       at Janus.Windows.UI.CommandBars.UIContextMenu.Show(Control control, Point pos)
       at Janus.Windows.EditControls.UIButton.DropDown()
       at Janus.Windows.EditControls.UIButton.OnMouseDown(MouseEventArgs e)
       at System.Windows.Forms.Control.WmMouseDown(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at Janus.Windows.EditControls.UIButton.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.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.Run(Form mainForm)
       at Behdasht.Program.Main() in D:\Projects\Behdasht 20110709\BehdashProject\Behdasht\Behdasht\Program.cs:line 16
       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException:</t>
Posted
Updated 12-Jul-21 17:33pm
v3
Comments
Herman<T>.Instance 6-Feb-12 5:32am
   
Have you changed you ConnectionTimeOut? It is default set to 15 seconds

Usually The Default Connection Timeout for SQL Server Is 15 Secs.

Please Check The Connection Timeout.

If You Want To Increase The Idle Time Then Increase The Connection Timeout of SQL Server.

And Also Handle The Exception After The Timeout. Rather Give a Proper Message To The User About The Connection Timeout.
   
v2
Comments
Hamid Noahdi 12-Feb-12 2:24am
   
Thanks. But i increased the timeout but no different yet.

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