K
K
kramick2021-07-24 17:25:55
Python
kramick, 2021-07-24 17:25:55

How to connect to a socket from the internet?

I started learning about sockets in python. My goal was to write a back-end so that it can be connected to from the internet . Wrote the server and the client part on the computer. Everything works perfectly.
I tried to connect from the phone and inside my Wifi - everything works . But as soon as I switch to the mobile network - nothing works. I'm trying to connect up to a terrible error (see below). How can I connect from the Internet to the server?

Traceback (most recent call last):
File "<path>", line 31, in <module>
start(fakepyfile,mainpyfile)
File "<path>", line 30, in start
exec(open(mainpyfile).read(), __main__.__dict__)
File "<string>", line 27, in <module>
File "<string>", line 9, in __init__
TimeoutError: [Errno 110] Connection timed out


PS I use Pydroid 3 for Android

Answer the question

In order to leave comments, you need to log in

2 answer(s)
H
Hanneman, 2021-07-24
@Hanneman

Connection timeout - a terrible mistake?
Here you write: "I tried to connect from the phone and inside my Wifi - everything works. But as soon as I switch to the mobile network, nothing works." - don't you understand that your devices in this case are in completely different networks and from where and how from the mobile network the device will "see" the device that is in your home local network?
Your server must have a white address - i.e. An IP that is visible from the global Internet so that it can be connected to from anywhere.
You can purchase this address from your ISP.

S
Sergey Gornostaev, 2021-07-24
@sergey-gornostaev

To write network applications, you need to understand how networks work.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question