matrix-org / sygnal

Sygnal: reference Push Gateway for Matrix
Apache License 2.0
167 stars 148 forks source link

Synapse not able to access Sygnal in docker compose #399

Closed theobouwman closed 1 month ago

theobouwman commented 1 month ago

I want to use Synapse with Sygnal for push notifications.

When I register a pusher, and a new push notification is sent I get this error stating that the Sygnal instance is blocked?:

synapse-1                | 2024-10-29 22:00:12,087 - synapse.push.httppusher - 236 - INFO - httppush.process-17 - Processing 2 unprocessed push actions for @deff67df-8c84-4782-87cb-5d2ce6b2c59f:test.my.com/com.my.app/xxxxxxxx starting at stream_ordering 589
synapse-1                | 2024-10-29 22:00:12,101 - synapse.http.client - 202 - INFO - sentinel - Blocked 172.18.0.4 from DNS resolution to sygnal
synapse-1                | 2024-10-29 22:00:12,101 - synapse.http.client - 437 - INFO - httppush.process-17 - Error sending request to  POST http://sygnal:5000/_matrix/push/v1/notify: DNSLookupError no results for hostname lookup: sygnal
synapse-1                | 2024-10-29 22:00:12,101 - synapse.push.httppusher - 416 - WARNING - httppush.process-17 - Failed to push data to @deff67df-8c84-4782-87cb-5d2ce6b2c59f:test.my.com/com.my.app/xxxxxxxxx: <class 'twisted.internet.error.DNSLookupError'> DNS lookup failed: no results for hostname lookup: sygnal.
synapse-1                | 2024-10-29 22:00:12,101 - synapse.push.httppusher - 315 - INFO - httppush.process-17 - Push failed: delaying for 512s

What could be the issue here?

Here my config: docker-compose:

synapse:
    image: docker.io/matrixdotorg/synapse:latest
    restart: unless-stopped
    environment:
      - SYNAPSE_CONFIG_PATH=/data/homeserver.yaml
    volumes:
      - ./synapse/files:/data
      - ./synapse/synapse-modules/synapse_user_restrictions:/synapse_user_restrictions
    depends_on:
      - synapse-db
    networks:
      - default
    ports:
      - 8008:8008

  synapse-db:
    image: docker.io/postgres:12-alpine
    environment:
      - POSTGRES_USER=synapse
      - POSTGRES_PASSWORD=synapse
      - POSTGRES_INITDB_ARGS=--encoding=UTF-8 --lc-collate=C --lc-ctype=C
    volumes:
      - ./synapse/schemas:/var/lib/postgresql/data
    networks:
      - default
    ports:
      - 5433:5432

  sygnal:
    image: matrixdotorg/sygnal:latest
    restart: unless-stopped
    environment:
      - SYGNAL_CONF=/data/sygnal.yaml
    volumes:
      - ./synapse/sygnal:/data
    ports:
      - 5000:5000
    networks:
      - default

Code to setPusher:

client.setPusher({
                "app_display_name": "app",
                "app_id": "com.my.app",
                "data": {
                    url: "http://sygnal:5000/_matrix/push/v1/notify"
                },
                "device_display_name": `my device`,
                "kind": "http",
                "lang": 'en',
                "pushkey": pushToken,
                "enabled": true,
            })

From the Synapse container I am able to access the Sygnal server with curl: Screenshot 2024-10-29 at 22 57 44

ricardo-duarte-av commented 1 month ago

The issue is on Synapse side. In https://element-hq.github.io/synapse/latest/usage/configuration/config_documentation.html#ip_range_blacklist

This option prevents outgoing requests from being sent to the specified blacklisted IP address CIDR ranges. If this option is not specified then it defaults to private IP address ranges (see the example below).

ip_range_blacklist:
  - '127.0.0.0/8'
  - '10.0.0.0/8'
  - '172.16.0.0/12'
  - '192.168.0.0/16'
  - '100.64.0.0/10'
  - '192.0.0.0/24'
  - '169.254.0.0/16'
  - '192.88.99.0/24'
  - '198.18.0.0/15'
  - '192.0.2.0/24'
  - '198.51.100.0/24'
  - '203.0.113.0/24'
  - '224.0.0.0/4'
  - '::1/128'
  - 'fe80::/10'
  - 'fc00::/7'
  - '2001:db8::/32'
  - 'ff00::/8'
  - 'fec0::/10'
theobouwman commented 1 month ago

Thanks!