Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No Socket Received From uWebsockets.js likely due to an invalid host or busy port. #232

Closed
ChARCOOL opened this issue Feb 12, 2024 · 2 comments

Comments

@ChARCOOL
Copy link

ChARCOOL commented Feb 12, 2024

Everything works fine locally, but when I try to run the app on docker it gives me this error on listen No Socket Received From uWebsockets.js likely due to an invalid host or busy port.

I am running on MacOS (Apple Silicon).

Dockerfile

FROM node:18-alpine

RUN apk add --no-cache git gcompat gettext chromium

WORKDIR /app

RUN npm install --global pnpm
COPY package.json pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile

COPY . .

RUN pnpm run build
CMD ["node", "--experimental-specifier-resolution", "node", "dist/server"]

docker-compose.yml

version: "3.9"

services:
  cache:
    platform: linux/x86_64
    image: redis:7.2-alpine
    restart: always
    ports:
      - "6379:6379"
    command: redis-server --save 20 1 --loglevel warning
    privileged: true
    volumes:
      - cache:/data

  docgen:
    platform: linux/x86_64
    build: ./
    depends_on:
      - cache
    ports:
      - ${PORTS_API_DOCGEN}:${PORTS_API_DOCGEN}
    env_file:
      - .env
    environment:
      NODE_ENV: production
      DEBUG: false
      REDIS_HOST: cache
      CRAWLEE_DEFAULT_BROWSER_PATH: /usr/bin/chromium-browser
    links:
      - cache
    volumes:
      - ./:/src

volumes:
  cache:
    driver: local

app.ts (example)

import HyperExpress from "hyper-express";

const app = new HyperExpress.Server();

export default app;

PORT=44030
HOST=host.docker.internal

server.ts (example)

import app from "./app";

app.listen(environment.PORT, environment.HOST);

process.on("SIGINT", handleExit);
process.on("SIGQUIT", handleExit);
process.on("SIGTERM", handleExit);

function handleExit(signal: NodeJS.Signals) {
  app.close(() => {
    process.exit(0);
  });
}

package.json (Example)

  "scripts": {
    "build": "tsc -b"
  },
  "dependencies": {
    "@crawlee/browser-pool": "^3.7.3",
    "ajv": "^8.12.0",
    "async-lock": "^1.4.1",
    "cors": "^2.8.5",
    "dotenv": "^16.4.1",
    "fabric": "5.3.0",
    "hyper-express": "^6.14.12",
    "live-directory": "^3.0.3",
    "pino": "^8.18.0",
    "pino-http": "^9.0.0",
    "pino-pretty": "^10.3.1",
    "playwright": "^1.41.2",
    "redis": "^4.6.13",
    "sharp": "^0.33.2"
  },
  "devDependencies": {
    "@types/async-lock": "^1.4.2",
    "@types/cors": "^2.8.17",
    "@types/fabric": "5.3.6",
    "@types/node": "20.11.16",
    "prettier": "^3.2.4",
    "ts-node": "^10.9.2",
    "typescript": "5.3.3"
  }

tsconfig.json

{
"compilerOptions": {
  "target": "ESNext",
  "module": "ESNext",
  "lib": ["ESNext"],
  "allowJs": true,
  "strict": true,
  "forceConsistentCasingInFileNames": true,
  "moduleResolution": "Node",
  "resolveJsonModule": true,
  "esModuleInterop": true,
  "skipLibCheck": true,
  "isolatedModules": true,
  "incremental": true,
  "outDir": "dist",
  "rootDir": "src",
  "inlineSourceMap": true,
  "allowSyntheticDefaultImports": true,
},
"ts-node": {
  "experimentalSpecifierResolution": "node",
  "transpileOnly": true,
  "esm": true,
},
"include": ["src/**/*.ts"],
"exclude": ["node_modules"],
}
@kartikk221
Copy link
Owner

Could you try the following:

  • Try a different port like 80
  • Try running Node.js with root permissions (Just to test if its potentially a perms error to bind to the port you are attempting to bind to)

@ChARCOOL
Copy link
Author

@kartikk221, I will try. The weird thing is, for example, when I SSH into a Docker container and navigate to hyper-express/node_modules/uwebsockets.js, then create an example app.js, require it, and start listening on port 9001, it works perfectly fine. It also works fine locally as well.

@kartikk221 kartikk221 closed this as not planned Won't fix, can't repro, duplicate, stale Feb 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants