Failed to access server socket via internet python3

Asked

Viewed 23 times

0

Good afternoon, I have a problem, I need to access there my pi Raspberry through a socket but when I test locally the program works perfectly, but when I try to access it through the internet (having installed in Raspberry pi a dynamic dns so it is always available), but I can not contact the server through the socket, I can access it through the browser but I need for my application that I can access it from the socket.

the server code is like this :

import socket
import threading
bind_ip="127.0.0.1"
bind_port=80
server = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
server.bind((bind_ip,bind_port))
server.listen(1000)
def handle_client(client_socket):
    request=client_socket.recv(1024)
    print("[*]Recevid: ",request.decode('utf-8'))
    client_socket.send("teste".encode)
    client_socket.close()

while True:
    client,addr=server.accept()
    print("[*]Accepted connection from: ",addr[0]," ",addr[1])
    client_handler=threading.Thread(target=handle_client(client))
    client_handler.start()

I even tried to replace the 127.0.0.1 for 192.168.1.3 or even by the service of ddns in these attempts I only got the error that could not use that as ip server if someone can help me thank

1 answer

0

If you can with the browser, then probably the problem is in the client and not in your server. I hope I’ve helped.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.