<p>I have some dotnet core applications running as microservices into GKE (google kubernetes engine).</p>

<p>Usually everything work right, but sometimes, if my microservice isn't in use, something happen that my application shutdown (same behavior as CTRL + C on terminal).</p>

<p>I know that it is a behavior of kubernetes, but if i request application that is not running, my first request return the error: "<strong>No such Device or Address</strong>" or timeout error.</p>

<p>I will post some logs and setups:</p>

<p><a href="https://i.stack.imgur.com/gMRU9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gMRU9.png" alt="program.cs setup"></a></p>

<p><a href="https://i.stack.imgur.com/qIbOG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qIbOG.png" alt="gateway error log"></a></p>

<p><a href="https://i.stack.imgur.com/XrpXq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XrpXq.png" alt="microservice log"></a></p>

<p><a href="https://i.stack.imgur.com/oR2DY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oR2DY.png" alt="timeout error"></a></p>

<p><a href="https://i.stack.imgur.com/3zHKd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3zHKd.png" alt="application start running after sometime with database timeout error"></a></p>

Rodrigo Celebrone
<p>The key to what's happening is this logged error:</p>

<pre><code>TNS: Connect timeout occured ---&gt; OracleInternal.Network....
</code></pre>

<p>Since your application is not used, the Oracle database just shuts down it's idle connection. To solve this problem, you can do two things:</p>

<ol>
<li>Handle the disconnection inside your application to just reconnect.</li>
<li>Define a <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/" rel="nofollow noreferrer">livenessProbe</a> to restart the pod automatically once the application is down.</li>
<li>Make your application do something with the connection from time to time -> this can be done with a probe too.</li>
<li>Configure your Oracle database not to close idle connections.</li>
</ol>
