Can't connect WebSockex client to Socket.IO Server

Hello guys, how are you?

I’m trying to connect to a local server using WebSockex but when the application tries to run

WebSockex.start_link("ws://socket:8007", __MODULE__, state)

it always throws the error

** (EXIT) %WebSockex.ConnError{original: :closed}

The problem is that the server isn’t closed… I used docker-compose to run a server and a client container and with node it works.

Thats my server.js file:

const http = require("http").createServer();
const io = require("")(http);
const port = 8007;

var connectedClients = [];

http.listen(port, "", async () => {
  console.log("server listening on port:" + port);

io.on("connection", async (socket) => {
  socket.on("message", async (body) => {
      .emit("message", "Message sent successfully!");

    var command = JSON.parse(body);
    if (command.action == "add_alert") {
      io.emit("add_alert", command);
    } else {
      io.emit("add_alert", "error receiving alert!");

Thats my client.js file

const io = require("");

const socket = io.connect("ws://socket:8007");
socket.on("connect", () => {
  var obj =
    '{"action":"add_alert","data":{"user":{"id":1231298301283,"name":"Caio Borghi","phone":"+55900000000","alerts":[{"id":"hashID1","code":"ELET6","field":"Close","comparison":"<=","value":11.9,"message":"ELET6 Close price is lower than 11.9!"},{"id":"hashID2","code":"BBDC4","field":"Close","comparison":"<=","value":15.9,"message":"BBDC4 Close price is lower than 15.9!"}]}}}';
  socket.emit("message", obj);
  console.log("Client is Listening the Local connection.");

socket.on("add_alert", async (body) => {
  console.log("Alert received: " + JSON.stringify(body));

And in my docker-compose i`m connecting all 3 containers in the same network…

The big deal here is that the client container works perfectly pointing to the same URL that my Elixir application (ws://socket:8007) but when I try to connect through Elixir, it never works.

Do you know if there`s any config I need to change to be able to connect to “local” websockets with WebSockex? Or any tip of what I should try to make it work?

Thanks in advance, any help is welcome!