I'm trying to make communication via Internet between client and server, both written in Python. I have the next code for server:
def handle_client(clnt):
while True:
data = clnt.recv(1024)
if data:
print data,
del data
sock = socket.socket()
sock.bind(('0.0.0.0', 12345))
sock.listen(5)
while True:
client,addr = sock.accept()
print "[*] Accepted connection from: %s:%d" % (addr[0],addr[1])
# spin up our client thread to handle incoming data
client_handler = threading.Thread(target=handle_client,args=(client,))
client_handler.start()
client.close()
and for client:
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(('my public IP-address', 12345))
sock.send('Some plain text')
When working with localhost, it works properly. After i have loaded it to my Ubuntu-14.04 server, which is not in the same local network, client doesn't want to connect. The output is:
socket.error: [Errno 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
I have already created rule for server firewall, run server and client as administrator, disabled client antivirus, checked the Internet connection, pinged each other but it still doesn't seem to work throwing me the same error over and over again (the same error is shown if the server wasn't started).
Any ideas what`s wrong or how to fix this issue?