1

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?

Emelien
  • 55
  • 6
  • What is your network setup? Can you successfully access other services on the Ubuntu box? – roelofs Nov 22 '17 at 17:00
  • Server is connected directly to my Internet providers network, client - through router. Both have static IP and the same provider. Yes, i can. – Emelien Nov 22 '17 at 17:04
  • It's not unknown for providers to block certain port ranges or do other funny things. Try running something like apache on port 12345, and see if that works? – roelofs Nov 22 '17 at 17:08
  • Also, instead of using `0.0.0.0`, have you tried binding to the actual correct interface IP? – roelofs Nov 22 '17 at 17:09
  • Forgot to mention one more thing: this server is a VM in on my Proxmox venv. But when i was creating it (VM), i connected it directly. Proxmox is available from outer world. Yes, i tried. – Emelien Nov 22 '17 at 17:12
  • Can you confirm it using `telnet`? Like trying `telnet` on your servers public IP using a port of your Python server and then using another port that is open for sure like SSH’s 22 for a comparison example. – kuza Nov 22 '17 at 17:16
  • You can actually telnet to port 12345, and see if it connects. I know you've opened the ports, etc, but that doesn't mean something else (that you might not have control over) isn't blocking them. – roelofs Nov 22 '17 at 17:21
  • When connecting via telnet to 12345 port it fails. With 22 it feels good. What else except firewall can block connection in raw Ubuntu-14.04 server? – Emelien Nov 22 '17 at 17:31
  • Either tight network configuration of the `Proxmox` either something else you have yet to disclose to give a better clue. I am not familiar with Proxmox but try the suggestion of [second post](https://forum.proxmox.com/threads/how-do-i-access-vms-from-internet.4885/) on their forum. – kuza Nov 22 '17 at 18:24
  • Not my case. There is no router between server and my isp. The line from isp with several IPs connects to switch, from there it goes separately to server and router. Proxmox, VMs and router has different addresses. – Emelien Nov 23 '17 at 07:24

0 Answers0