I am using psycopg2 version 2.6.1, whenever I run a query to a remote server, if its less than 3 minutes it will run perfectly, but if it runs for more than 3 minutes it gets killed.
I am connecting and executing the query by the following way (client side):
import psycopg2
con = psycopg2.connect("dbname=DB user=DB_User host=192.168.1.100 password=WriteRandomPassword")
cur = con.cursor()
cur.execute('select * from Random_schema.Random_Table')
In the logs in the Postgres server I get (server side):
LOG: could not send data to client: Connection reset by peer
Doing a tcpdump the client sends a "R" (Reset) Flag to the Postgres server and kills the connection.
If I run the same query but using the Postgres server as localhost, the query runs for the time it needs to, its only when I try to access it as remote.
PS. I am using Postgresql 9.4.