2👍
There are many different causes for this error:
Configuration of your connection pool
Check if your connection pool has parameters like timeout or lifetime. I have had issues myself with this parameter causing the error ORA-03135 after one minute of inactivity of a pooled session. The solution in my case was using non pooled connections, but that is not viable for most applications. In your case, setting a higher timeout might do the trick.
Try to activate the highest level of debug on DJango and/or the Middleware to see if it logs messages about sessions expiring in the pool. Restart the Middleware and time how long it takes to start failing. If it is a short period of time (e.g. 60 seconds), you might want to change the timeout and make sure that the pool has enough sessions for your load.
Network Errors / Firewall
All kinds of network problems such as dropped packets or network card issues can cause the connection to drop.
In order to debug this one, connect to the database using Sqlplus and run any given command. After that, leave the session inactive for 10,20,30,60 and 120 minutes (one attempt at a time). This will let you know if the problem happens only through a connection pool or with SQLPLUS as well. If the latter is true, then it might be a network problem or configuration (such a firewall timeout) that is killing the session due to inactivity. This is especially true if the session always dies after the same interval (e.g. after two hours). Try the same experiment on other machines to see if the timeout still occurs. If it only occurs from certain hosts, it might be an issue with the switch to which the host is connected to. Your network engineers might need to get involved.
The OS Keepalive configuration might help in this case. Below is a link for Windows. http://blogs.technet.com/b/nettracer/archive/2010/06/03/things-that-you-may-want-to-know-about-tcp-keepalives.aspx
Another way to go about debugging such errors is enabling TNS tracing on the client and/or server. This is done by configuring parameters as TRACE_LEVEL_CLIENT and TRACE_LEVEL_SERVER respectively on the client and server sqlnet.ora files. There are other parameters required to get this going. Check the Oracle documentation on the subject.
Oracle Server side disconnection
The database may disconnect a session because of an issue with it, a bug in Oracle or when the sessions is killed by the administrator. The best way to diagnose such issues is looking into the database alert.log matching the time when you got the error with the log contents. If the session died on the server, there will be an entry stating that the sessions was terminated and the path to a trace file containing additional information about the disconnection. If it is an Oracle bug that is causing it, you will have to search for the proper fix through Oracle Support.
Also, the user may be associated to an Oracle Profile that has a configured the CONNECTION_TIME or IDLE_TIME. In order to debug if this is the cause of the issue, associate the user with an Oracle profile without such restrictions.