1

I'm working on an application that gets timeout exceptions often. I'm trying to test a fix we did to handle the errors, but to do that I need to replicate timeout exceptions.

Connection string:

<connectionStrings>
    <add name="Entities" 
         connectionString="metadata=res://*/DataModel.csdl|res://*/DataModel.ssdl|res://*/DataModel.msl;provider=System.Data.SqlClient;provider connection string='Data Source=localhost;initial catalog=Name;Command Timeout=30;persist security info=True;user id=User;password=user_pwd;MultipleActiveResultSets=True;App=EntityFramework'" 
         providerName="System.Data.EntityClient" />
</connectionStrings>

My idea was to lower the timeout exception binding in the Entity Framework connection string, but when I add it it says the keyword is not supported.

I've also tried :

  1. Command Timeout
  2. CommandTimeout
  3. ConnectionTimeout

Does anybody have an idea? I'm starting to think my connection string is immutable lol.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
J.L
  • 51
  • 2
  • 7
  • Did you try `Connection Timeout=XX` (where XX is seconds)? I do not see it in the connection string you have in the question. See also [EntityConnection.ConnectionString Property](https://msdn.microsoft.com/en-us/library/system.data.entityclient.entityconnection.connectionstring(v=vs.110).aspx) – Igor Apr 27 '18 at 20:36
  • You're probably on the wrong track anyway. Connection timeout is not the same thing as command timeout which I think you're struggling with. That can't be set in the connection string. https://stackoverflow.com/q/36977974/861716 – Gert Arnold Apr 27 '18 at 21:28
  • You're right. I was looking for Command Timeout. Still not a recognized keyword though. I'm definitely doing something wrong lol. – J.L Apr 30 '18 at 14:22
  • *Still not a recognized keyword though* Duh. Did you see the answer I referred to? – Gert Arnold May 02 '18 at 07:35

1 Answers1

-3

You can append ;Connection Timeout=30 to your connection string and specify the value you wish.

The timeout value set in the Connection Timeout property is a time expressed in seconds. If this property is not set then timeout value for the connection is the default value which is 15 seconds.

Moreover, setting the timeout value to 0, you are specifying that your attempt to connect waits an infinite time. As described in the documentation, this is something that you should not set in your connection string.

Azeem Hafeez
  • 250
  • 4
  • 14