[Python] TCP socket communication (Android SDK java to PC python) works on wifi but doesn't...

Discussão em 'Python' iniciado por Stack, Outubro 3, 2024.

  1. Stack

    Stack Membro Participativo

    I have a server client socket communication between an android phone application (made using android SDK) and a laptop. On my home wifi, this works as intended with the phone (server) providing the IP through InetAddress.getHostAddress() and the laptop (client) connecting with socket.socket(socket.AF_INET, socket.SOCK_STREAM) and connect((ip, port)).

    However, running the same programs while the two machines are connected to another phone's hotspot results in:

    ConnectionRefusedError: [Errno 111] Connection refused

    To further test this, I made basic server/client socket programs (written in java and python to mirror the phone and PC's programs) on the same machine and ran them while on the hotspot. This seems to work fine.

    Next, I ran those same server/client socket programs on two different machines (two laptops, linux and windows) and resulted in:

    ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it.

    For the two laptops, this seems to happen both on the home wifi and on the hotspot.

    To reiterate:


    • phone server (android, java) to client PC (linux, python) on home wifi: Works as intended


    • phone server (android, java) to client PC (linux, python) on hotspot: Doesn't work


    • PC server (linux, java) to client same machine (python) on hotspot: Works as intended


    • PC server (linux, java) to client PC (windows on anaconda, python) on wifi: Doesn't work


    • PC server (linux, java) to client PC (windows on anaconda, python) on hotspot: Doesn't work

    For all these tests, the server is running on localhost.

    Any advice and help on solving this issue would be greatly appreciated, particularly in figuring out the communication between the phone and laptop. Thanks!

    Continue reading...

Compartilhe esta Página