How to increase the DB connection Timeout - mule

I have got the connection Timeout in DB. Already I have set connection Timeout to '60sec' in DB. I got the below error. After connecting with DB people ,have found that. The below error is not query command timeout and mostly of connection establishing Mule to DB timeout. I have a doubt
Here Connection Time= 60sec ( means once it reached DB, time to wait to execute the query). Is it correct.
But then how to increase the connection Time out ?, Going through the link
http://www.mulesoft.org/documentation/display/current/Database+Connector+Examples.
Thought to provide maxWaitMillis = 20000 as below. But not sure this is correct ( Because document talks about connection polling and cache, but I dont want cache all over here).
Is it fine, without giving any other value inside connection polling. Just by giving maxWaitMilli timeout is correct for my case or I'm wrong. All I need is need to resolve the below error. Please suggest.
Error:java.sql.SQLException: Cannot get connection for URL jdbc:sqlserver://c01.company.com;database=**;user=***;password=***** : The TCP/IP connection to the host 01.company.com, port 022 has failed. Error: "connect timed out. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.". (org.mule.module.db.internal.domain.connection.ConnectionCreationException). Message payload is of type: String
<db:generic-config name="DB" url="${db}"
driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver"
doc:name="Generic Database Configuration" connectionTimeout="60">
<db:pooling-profile maxWaitMillis="20000"/>
</db:generic-config>
<db:stored-procedure config-ref="DB" doc:name="GetOrderXML">
<db:parameterized-query><![CDATA[{call GetDetailXML('10', ?)}]]></db:parameterized-query>
<db:in-param name="ln" type="CHAR" value="#[flowVars['ID']]"/>
</db:stored-procedure>
Thanks in advance.

maxWaitMillis attribute in db pooling profile is the number of milliseconds a client calling getConnection() will wait for a Connection to be checked-in or acquired when the pool is exhausted. Zero means wait indefinitely.
The other timeout value is the connection timeout which the amount of time a database connection remains securely active during a period of non-usage before timing-out and demanding logging in again.
Both in the link below:
http://www.mulesoft.org/documentation/display/current/Database+Connector+Reference
The query timeout was available in the old jdbc connector (which I assume it will set the JDBC statement queryTimeout attribute) but I cannot find in the new db connector.
http://www.mulesoft.org/documentation/display/current/JDBC+Transport+Reference

Related

Sporadic Azure SQL Semaphore Timeout/Handshake error when connecting as login, but login#servername seems to work?

I am having issues reliably connecting to Azure SQL Databases from on-prem. (so yes, firewalls involved). When I connect (SSMS or invoke-sqlcmd) using just mylogin, sometimes it works but frequently I'll get a message like:
Connection timeout expired. The timeout period elapsed while attempting
to consume the pre-login handshake acknowledgement. this could be
because the pre-login handshake failed or the server was unable to
respond back in time. the duration spent while attempting to connect
to this server was 0 [Pre-Login] initialization=67;handshake=14948;
However, I've noticed that if I connect as mylogin#the-server-name (not the FQDN, just the part of the servername we can choose) then it seems to be a lot more reliable.
Is this something I can do something about? Firewall weirdness? Any help appreciated.
Looking in the ring buffer ( SELECT CAST(record as xml) as record FROM sys.dm_os_ring_buffers WHERE ring_buffer_type = 'RING_BUFFER_CONNECTIVITY') I have records, but I'm not seeing anything about failed connections, just killed connections. (and totallogintimeinmilliseconds is null)

Jedis pool configuration for get and set/flush operations

I am new to redis and using Jedis client in my application. I have gone through couple of threads and did not find the conclusive answers.
I have 2 questions where I need clarity.
For my production use I want to set separate timeout for jedis get operations and set operations. For all set operation I want to set timeout to 2000ms and for get 100ms. I have implemented below configuration.
JedisPoolConfig poolConfig = new JedisPoolConfig();
poolConfig.setMaxIdle(30);
poolConfig.setMinIdle(10);
poolConfig.setMaxWaitMillis(2000);
jedisPool = new JedisPool(poolConfig, RedisDBUrl, port, 100);
Let me know if above configuration will do the job. I am setting read timeout to 100ms and maxwait to 2000ms.
Let me know if my understanding is correct.
At times I get JedisConnectionException: java.net.SocketTimeoutException: Read timed out or sometimes connect timeout.
Here connect time out is thrown when my application is not able to make connection to redis withing configured time?
Secondly, read timeout comes when application is connected to redis but operations(get/set) are taking time or for some reason?
Lastly, how do i configure timeout for read timeout and connect timeout?
After many hit and trial and some test runs found out, you can not set separate timeout for jedis get and set operations.
May be you can use some external library to achieve(Like google's SimpleTimeLimiter.
Further from what I have observed connect timeout occurs when jedis tries to connect to redis server. In my case my redis server latency from my system is ~120-125ms so if I set timeout=100ms in jedis constructor I get "connect time out".
Whereas "read time out" comes when you are connected to redis server but redis operation doesn't return in specified time. To test this scenario I have set the timeout in constructor to 180ms and tried to run the flushall operation(takes long time), here I got read timeout.
Still not sure though whats the significance of poolConfig.setMaxWaitMillis().

Worklight SQL Adapter Idle Timeout

Is there a way to create and idle time out in the sql adapter.
Right now im getting java.net.SocketException: Broken pipe exceptions when the connection has been idle and the DB has cut it off.
Thanks
Adapter simply rides on top of your jdbc pool. Try configuring idle connection properties for it, e.g. for Tomcat - http://people.apache.org/~fhanik/jdbc-pool/jdbc-pool.html (search for "idle")

How to add timeout while opening SSH session (using ganymed-ssh2-build210.jar)?

I am using ch.ethz.ssh2.Connection.Connection object from ganymed-ssh2-build210.jar
I want to add timeout while establishing connection to server so that if it fails to open connection, after certain time it should throw some exception.Can anyone help on how to add timeout while establishing connection using connect method?
Thanks in advance,
Devayani
There is a timeout parameter to one of the connect methods: http://www.cleondris.ch/opensource/ssh2/javadoc/ch/ethz/ssh2/Connection.html#connect(ch.ethz.ssh2.ServerHostKeyVerifier,%20int,%20int)

Connection Problems With Mirrored Database

The setup is as follows:
A C++ client connects via OLEDB/SQL Native Client to a SQL Server 2005 database located on another machine. The server is setup with mirroring (automatic failover) with a synchronized server located on yet another server and a witness server on another server.
Occassionally (once every couple of days), our application seizes up in that it appears to attempt to establish a database connection to the database and rather than simply failing and OLEDB throwing a database connection failure it just gets "stuck" (we have a timeout for the connection but it's never timing out). 24 to 36 hours later we'll get an error:
TCP Provider: An existing connection was forcibly closed by the remote host.
And things will continue you on with lots of these errors and our app will eventually need to be restarted. We can't really figure out what condition could be causing this behavior and what we can do about it?
In preliminary research, I've seen some related problems that were solved by setting the Connection Lifetime connection string property to something non-zero.
Does anyone have any thoughts on what might be going on here?