WhatsApp / WhatsApp-Business-API-Setup-Scripts

The scripts related to setting up WhatsApp business API
MIT License
410 stars 433 forks source link

Can't perform any requests (SSL?) #34

Closed jdc-developer closed 3 years ago

jdc-developer commented 4 years ago

Hello. I've been trying to run the service in my web server and also locally, and I couldn't in both of them. I'm not proficient in docker, but I could manage to follow the steps in the tutorial. When I finally got the service running, I can't make any requests into it. It always refuses the connection. I verified many times the environment data and everything and it's okay. The main tutorial doesn't mention any SSL compulsoriness. The server shows running ok in the docker list, also I tried what's in https://developers.facebook.com/docs/whatsapp/guides/security but I am not sure if I did right. Here's my compose:

version: '3'

volumes:
  whatsappMedia:
    driver: local

services:
  wacore:
    image: docker.whatsapp.biz/coreapp:v2.27.12
    command: ["/opt/whatsapp/bin/wait_on_postgres.sh", "/opt/whatsapp/bin/launch_within_docker.sh"]
    volumes:
     - whatsappMedia:/usr/local/wamedia
    env_file:
      - db.env
    environment:
      WA_DB_SSL_KEY: "private.key"
      WA_DB_SSL_CERT: "certificate.crt"
      WA_DB_SSL_CA: "ca_bundle.crt"
      WA_WEB_SECURITY_LEVEL: MODERN
      WA_SECRET: De8tr5ct1lljS
      # This is the version of the docker templates being used to run WhatsApp Business API
      WA_RUNNING_ENV_VERSION: v2.2.3
      ORCHESTRATION: DOCKER-COMPOSE
    network_mode: bridge
  waweb:
    image: docker.whatsapp.biz/web:v2.27.12
    command: ["/opt/whatsapp/bin/wait_on_postgres.sh", "/opt/whatsapp/bin/launch_within_docker.sh"]
    ports:
     - "1010:443"
    volumes:
     - whatsappMedia:/usr/local/wamedia
    env_file:
      - db.env
    environment:
      WA_DB_SSL_VERIFY: 0
      WA_DB_SSL_KEY: "private.key"
      WA_DB_SSL_CERT: "certificate.crt"
      WA_DB_SSL_CA: "ca_bundle.crt"
      WA_WEB_SECURITY_LEVEL: MODERN
      WA_SECRET: De8tr5ct1lljS
      WACORE_HOSTNAME: wacore
      # This is the version of the docker templates being used to run WhatsApp Business API
      WA_RUNNING_ENV_VERSION: v2.2.3
      ORCHESTRATION: DOCKER-COMPOSE
    depends_on:
      - "wacore"
    links:
      - wacore
    network_mode: bridge

So the cert files are on the same folder as the compose, is that right, and it makes sense? Also the lack of SSL makes the app impossible to reach? The debug logs me these messages: Database is not up yet - sleeping getaddrinfo: Name or service not known

What this means? When I change the WA_DB_HOSTNAME to localhost, it shows only Database is not up yet - sleeping, so what's wrong? I guess I must tell it which databse on server it should connect, but how do I do that?

I tried Wadebug with MySql locally and it has shown all right, except on the end when it tried to make requests into the server, so it failed with SSL EOF errors...

If you may, please, help me.

mengyiyuan commented 4 years ago

Can you verify if you issue is similar to #31 ? If so, please follow the instructions in that issue to resolve.

Besides, if you run everything locally for testing purpose, please follow the guide in https://developers.facebook.com/docs/whatsapp/installation/dev-single-instance, which sets up waweb, wacore and mysql containers for you.

If you want to run in a production environment with a standalone mysql instance (not on localhost), follow the instructions in #31 on how to set up SSL certs.

Running a separate mysql container in localhost may have network issues because of how docker network works. https://docs.docker.com/network/

Rajamohanreddyai commented 3 years ago

Hello ,

I was created the whole setup at that time I got the same error, but at the next second I was fixed the same. Mainly because of 2 reasons you may get the URL not found errors.

Containers are not up (db, coreapp, webapp). You might be calling the wrong URL. Please check the below link if do you want any clarity. https://youtu.be/hYO32rQQ9Pc