Docker Community Forums

Share and learn in the Docker community.

Web socket connection doesn't work inside Docker Container

I’m writing a Java app that needs to connect to a database backend. The connection is handled by the database SDK (Couchbase in this case), which starts up a replicator to a specific endpoint (wss://). When running this app from the IDE or by running the executable from the command line, everything works fine. However, when I build the Docker image, and then run the image in a container, the web socket connection fails to connect. From the log output, I can see that it gets stuck on “connecting”:

ReplicatorChange{replicator=Replicator{@450b4ee,<-,Database{@247240e5, name='<redacted>'},URLEndpoint{url=wss://<redacted>:443/data}], status=Status{activityLevel=CONNECTING, progress=Progress{completed=0, total=0}, error=null}}

Once the app reaches the above line, it gets stuck there and nothing happens. And it’s not a network issue, because HTTP connections work fine, since prior to this, the app creates a session by calling an HTTP endpoint.

I’m fairly new to Docker, so is there anything in the container that is preventing the replicator from connecting? I’ve looked into EXPOSE in the Docker file, and running with -p or -P, but none have worked so far.

Just as a clarification, though, the app itself is not a server. It could be considered a “job” app – it does some work at the request of client apps, persists that work to the database, and then closes. In order to persist the work it does to the database, it establishes a connection to a wss:// endpoint that basically handles data transmission back-and-forth. It’s that connection that fails. The database SDK (Couchbase) never updates the status of the replicator once it attempts to connect, which suggests it’s stuck waiting on a response maybe?

The endpoint it connects to (wss://[redacted]:443/data) is controlled by us, so are you suggesting the change might need to occur there in order to listen for requests coming in?