I have a TCP server that listens to clients requests. It works without any issues when running it and executing the requests on a local environment.
The server is deployed in Azure Container Instances using Docker. I have been troubleshooting and the
socket.accept() is returning a None object when running in a Docker image (both in local and Azure).
def __init__(self, ip_address, port): self.ipAddress = ip_address self.port = port self.server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.server_socket.bind((self.ipAddress, self.port)) self.server_socket.listen(1) self.secure_socket = None self.worker = None def connect(self): print("client connection before accept" ) (client_connection, client_address) = self.server_socket.accept()
Running locally the server with an IP of 0.0.0.0 define at the server, allows the client to connect to the server 0.0.0.0:port. However, when I run this in docket the
accept() method is not returning a socket and I think the issue is related with the IP address.
If the client is hosted in localhost, but the docker is running on local Docker, I see that the client ‘hits’ the server raising an exception, but never creates a valid socket.
The biggest issue that I face is deploying this in Azure Container Instances, since this service will give me a dynamic IP and I don’t wish to create a static IP for this project.
Source: Docker Questions