|
|
|
 |
Reply From: |
godot_dev_ |
If I understand correctly, you have the following setup:
-
Internet ------ (IP1) external router ------ (IP2) internal router ----- (IP3) PC hosting python
It could be due to the following
-
The external IP address (IP1 above) is wrong (check this site to confirm what your external IP address is)
-
It could be a firewall issue on the device hosting the Python scripts. Make sure to create a rule in you firewall to allow incoming connections on port 9999
-
It could be an anti-virus issue. Some anti-viruses have their own firewall (I think McAfee does this). So also create a rule for port 9999 if this is the case
-
You may have incorrectly configured you external router when opening the port.
-
Double check to make sure the port 9999 is being forwarded to your internal router
-
Double check and confirm your internal router’s IP address IP2 above) is properly tied to open port 9999 rule
-
You may have incorrectly configured you internal router when opening the port.
-
Double check to make sure the port 9999 is being forwarded to your PC hosting the python script
-
Double check and confirm your PC’s IP address (IP3 above) is properly tied to open port 9999 rule
-
Make sure your python script is implemented correctly by having a local device (connected to the internal router) ping (or otherwise try and communicate with) the Python script. If communication doesn’t work on a LAN, you have a Python script issue.
-
Note that sometimes the IP address of devices change on a LAN (due to new devices connecting and what not). This might be the source of the issue. You can configure your routers to assign static IP address based on MAC addresses to the devices involved in your setup. This will limit the possibility for error
-
If you double checked all the above, the only last thing I can think of is making sure the Python script is running and can be pinged when you perform the open port checker
I’ve set my machine to a static ip out of the dhcp range and I did use the right ip wich I got from whatismyip.com and also using curl ifconfig.me in the cmd.
here is the python script I don’t really know how it works or it might be set up wrong:
import socket
HOST = 'my-external-ip' # set the host IP address to listen on
PORT = 9999 # set the port number to listen on
# create a socket object
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.bind((HOST, PORT)) # bind the socket to the host and port
s.listen() # listen for incoming connections
print(f'Listening on {HOST}:{PORT}...')
conn, addr = s.accept() # accept the connection
with conn:
print(f'Connected by {addr}')
while True:
data = conn.recv(1024) # receive data from the client
if not data:
break
conn.sendall(data)
this script works when I leave the HOST empty. but when I put in my external Ip it won’t work and won’t listen to anything. it throws this error:
Traceback (most recent call last):
File “C:\Users\fuck you billGates\Desktop\PORT.py”, line 8, in
s.bind((HOST, PORT)) # bind the socket to the host and port
^^^^^^^^^^^^^^^^^^^^
OSError: [WinError 10049] The requested address is not valid in its context
Cyber-Kun | 2023-04-27 09:07
I also made rules in windows defender firewall>advanced>inbound rules to allow all connections on both tcp and udp ports 9999
Cyber-Kun | 2023-04-27 09:13
I believe the problem might be in the python script but I’m not sure. I will double check all the port forwarding rules on both routers. also the first router IP1 has a virtual server setting and port forwarding. from my understanding their both the same but should I maybe set a rule in virtual server as well since I only set the port forwarding rule?
Cyber-Kun | 2023-04-27 09:18
I was also considering using another port from 9999 as when i use a port checking service it says that the default ports like 80 are open but not port 9999
Cyber-Kun | 2023-04-27 09:28
I found a setting on the access point called WAN Port Ping and it’s disabled. should it be enabled?
Cyber-Kun | 2023-04-27 09:44
ok I seem to be having trouble setting up the access point(IP2) to have a static IP address on the main router. it’s unfortunately a HUAWEI B315. when I navigate to Ethernet settings I can choose the connection mode but even though I set it to static there on the main router it just shows the dynamic IP .151 instead of what I try to set it to
Cyber-Kun | 2023-04-27 10:34
According to a Python echo server guide, the address to use when binding is 127.0.0.1 (aka, localhost), not the external IP. I think this is because your telling the server that you will be hosting on this machine, not connecting to another server. Try changing the IP to 127.0.0.1 in your python script
godot_dev_ | 2023-04-27 13:42
Also, I recommend the first step you should focus on is getting your python script to work on a LAN without any router configuration (have it send a message back to a clientmachine on the same LAN as the python server). All the router config is futile is your python script is buggy.
godot_dev_ | 2023-04-27 13:59