androidseb25 / iGotify-Notification-Assistent

Docker container for sending Gotify notifications to iOS devices (bridge to gotify websocket)
MIT License
99 stars 3 forks source link

[BUG] Gotify Server is not available #56

Open Teonyr opened 2 months ago

Teonyr commented 2 months ago

Describe the bug I've set up Gotify & iGotify according to the docker compose file found in this repository. Gotify itself is working and I can connect with my phone (through iGotify app) or via webbrowser and I can see Notifications. However I dont receive push messages on my phone and looking at the log I see the error messages you can read below in "Log".

Expected behavior Everything should work.

Used Docker Compose

version: "3.8"
services:
  gotify:
    container_name: gotify
    hostname: gotify
    image: gotify/server
    restart: unless-stopped
    security_opt:
      - no-new-privileges:true
    networks:
      - backend
    labels:
      traefik.enable: true
      traefik.http.routers.gotify.entrypoints: web, websecure
      traefik.http.routers.gotify.tls: true
      traefik.http.routers.gotify.rule: ( Host(`gotify.REDACTED`) )
      traefik.http.services.gotify.loadbalancer.server.port: 80
    volumes:
      - /persistent/gotify/data:/app/data
    env_file:
      - .env
  igotify:
    container_name: igotify
    hostname: igotify
    image: ghcr.io/androidseb25/igotify-notification-assist:latest
    restart: unless-stopped
    security_opt:
      - no-new-privileges:true
    pull_policy: always
    networks:
      - backend
    volumes:
      - /persistent/gotify/api-data:/app/data
    labels:
      traefik.enable: true
      traefik.http.routers.igotify.entrypoints: web, websecure
      traefik.http.routers.igotify.tls: true
      traefik.http.routers.igotify.rule: ( Host(`igotify.REDACTED`) )
      traefik.http.services.igotify.loadbalancer.server.port: 8080
networks:
  backend:
    external: true

Contents of .env

TZ=Europe/Berlin
GOTIFY_DEFAULTUSER_PASS=REDACTED

Smartphone (please complete the following information):

Log

22.04.2024 09:25:09 Database is created: True 22.04.2024 09:25:10 Gotify Server is not available try to reconnect in 10s. 22.04.2024 09:25:10 info: Microsoft.Hosting.Lifetime[14] 22.04.2024 09:25:10 Now listening on: http://[::]:8080 22.04.2024 09:25:10 info: Microsoft.Hosting.Lifetime[0] 22.04.2024 09:25:10 Application started. Press Ctrl+C to shut down. 22.04.2024 09:25:10 info: Microsoft.Hosting.Lifetime[0] 22.04.2024 09:25:10 Hosting environment: Production 22.04.2024 09:25:10 info: Microsoft.Hosting.Lifetime[0] 22.04.2024 09:25:10 Content root path: /app 22.04.2024 09:25:20 Reconnecting... 22.04.2024 09:25:20 Gotify Server is not available try to reconnect in 10s. 22.04.2024 09:25:30 Reconnecting... 22.04.2024 09:25:30 Gotify Server is not available try to reconnect in 10s.

Additional Information The app/service I used, to test if gotify itself works, is Jellyseerr. It is deployed by docker compose too, uses also the "backend" network and does connect to gotify via: http://gotify. grafik

I would greatly appreciate any help. If you need more information, I'm happy to deliver them.

androidseb25 commented 2 months ago

can you try the IP of the container instead of http://gotify to look if he can communicate in you're network?

Teonyr commented 2 months ago

I used the IP (172.18.0.85) of my gotify container inside Jellyseerr and had no problem connecting to the gotify server and sending a notification.

How does iGotify determine the address of the gotify server? In the past there seems to have been an environment variable, but I read in some change notes, that it's no longer needed.

Teonyr commented 2 months ago

After installing ping (apt-get install iputils-ping) inside the igotify container, I checked if the container can reach my gotify server container:

root@igotify:/app# ping gotify
PING gotify (172.18.0.85) 56(84) bytes of data.
64 bytes from gotify.backend (172.18.0.85): icmp_seq=1 ttl=64 time=0.760 ms
64 bytes from gotify.backend (172.18.0.85): icmp_seq=2 ttl=64 time=0.102 ms
64 bytes from gotify.backend (172.18.0.85): icmp_seq=3 ttl=64 time=0.102 ms
64 bytes from gotify.backend (172.18.0.85): icmp_seq=4 ttl=64 time=0.041 ms
64 bytes from gotify.backend (172.18.0.85): icmp_seq=5 ttl=64 time=0.036 ms
root@igotify:/app# ping 172.18.0.85
PING 172.18.0.85 (172.18.0.85) 56(84) bytes of data.
64 bytes from 172.18.0.85: icmp_seq=1 ttl=64 time=0.633 ms
64 bytes from 172.18.0.85: icmp_seq=2 ttl=64 time=0.095 ms
64 bytes from 172.18.0.85: icmp_seq=3 ttl=64 time=0.047 ms
64 bytes from 172.18.0.85: icmp_seq=4 ttl=64 time=0.032 ms

As you can see there is no problem in reaching it. So my guess would be, that iGotify doesn't know the correct address of my gotify server container.

androidseb25 commented 2 months ago

I used the IP (172.18.0.85) of my gotify container inside Jellyseerr and had no problem connecting to the gotify server and sending a notification.

How does iGotify determine the address of the gotify server? In the past there seems to have been an environment variable, but I read in some change notes, that it's no longer needed.

yes iGotify is now configured over the app, in the data folder you find a users.db with the informations that's the reason of my question, maybe he can't redirect to the gotify server or something happend with traefik that he don't redirect correctly. (I'm not a traefik expert, the whole conf of traefik comes from other users)

androidseb25 commented 2 months ago

So my guess would be, that iGotify doesn't know the correct address of my gotify server container.

please create an instance of the ip and port where the container is running. maybe it helps

Teonyr commented 2 months ago

Okay, I now created a new instance inside the iOS App with the ip-address and port of my homeserver, which is running the two containers. It works now - thanks for the help. 👍🏻

However for me this doesn't quite feel like a solution, since I have two containers running alongside each other, both on the same docker network and both can ping and reach each other, yet I need to set ip addresses in a different app to make it work. :/

androidseb25 commented 2 months ago

However for me this doesn't quite feel like a solution, since I have two containers running alongside each other, both on the same docker network and both can ping and reach each other, yet I need to set ip addresses in a different app to make it work. :/

normally it works, in my homelab it works with the docker network address for gotify http://gotify (i use npm), i really confused, maybe it's really the traefik that routes wrong?

Teonyr commented 2 months ago

How does your iPhone connect directly to docker containers via their name?

Since my iPhone isn't part of my docker network, it doesn't know http://gotify so the iOS app complains, that it can't reach a gotify server.

My phone (the iOS igotify app) should use: https://gotify.myhome.network and https://igotify.myhome.network While the two containers should talk over the docker network via http://gotify and http://igotify

But since the environment variable is gone, i think there is currently no way to set it up like this 🤔

androidseb25 commented 2 months ago

in my network it works because i don't split the wlan an lan network

i have an raspi with docker running where gotify and igotify-container are deployed over the stack.

The names of the containers are the dns names and available in my network, e.g. from my iphone thats the reason why i can connect and he can connect without problems :)

vbartels commented 1 month ago

Hi, I have almost the same problem. Gotify works but no push notification. I set it up via portainer as stack with the exact configuration from the wiki (despite password and client token). ` igotify: container_name: igotify hostname: igotify image: ghcr.io/androidseb25/igotify-notification-assist:latest restart: unless-stopped security_opt:

igotify log says: `Gotify Server is not available try to reconnect in 10s.

Reconnecting...`

ping however works: root@igotify:/app# ping gotify PING gotify (172.18.0.2) 56(84) bytes of data. 64 bytes from gotify.gotify_net (172.18.0.2): icmp_seq=1 ttl=64 time=1.16 ms 64 bytes from gotify.gotify_net (172.18.0.2): icmp_seq=2 ttl=64 time=0.140 ms 64 bytes from gotify.gotify_net (172.18.0.2): icmp_seq=3 ttl=64 time=0.212 ms 64 bytes from gotify.gotify_net (172.18.0.2): icmp_seq=4 ttl=64 time=0.144 ms

androidseb25 commented 1 month ago

Hi did the app work?

Because you're config is deprecated

The new one didn't provide any environment variables by the iGotify section.

How do you configurate the app?

vbartels commented 1 month ago

Hi, yes - app works. I can send via curl and from my proxmox and see it in the gotify webinterface and igotify app on iphone. I fiddled a bit around tbh to get it running. But thats the config I copied from the current portainer stack config into the post.

androidseb25 commented 1 month ago

Did you have some firewall or an dns blocker between?

Please try to disable all and retry

Sometimes one of these thinks block the traffic

vbartels commented 1 month ago

No, both containers are in the same docker network. nothing between.. thats afaik the whole idea of a stack in portainer.

androidseb25 commented 1 month ago

th containers are in the same docker network. nothing between.. thats afaik the whole idea of a stack in portain

I was thinking about bringing back the environment variables without losing multiuser support

take a look at issue #59

jannesaarinen commented 1 month ago

I have the same issue. I believe for me this is caused because I use self signed sertificate and self signed custom CA within my homelab together with treafik.

From within iGotify container I can can see that the server IP address is resolved correctly for the Gotify traefik end point. But because iGotify container doesn't trust my self signed CA, the https calls fail.

If I expose the iGotify container port 8080 -> 80 and use the http://dockerhost:8080 as the Gotify server, it works correctly.

I belive #59 will also help me. If I would be able to define the gotify server as environment variable, I can point the igotify container to connect to gotify within the docker network with http and the igotify ios app can still use the https connection through traefik.

EDIT: I can fix the issue with the self signed certificates by running following commands on the docker host (assuming that you have the self signed root CA cert in the folder where you run these):

# Copy the CA cert to container
docker cp my-self-signed-ca.crt igotify:/usr/local/share/ca-certificates/

# Update the CA certs
docker exec -it igotify update-ca-certificates

EDIT2: Maybe there could be environment variable like "IGNORE_TLS_ERRORS=true" which would allow https with self signed certificates ?

dennisoderwald commented 3 weeks ago

I actually have exactly the same problem. My setup is also the two Docker containers (gotify, igotify) in a Docker network, proxy via npm.

The DNS entries are not publicly accessible but only within my tailscale network.

However, I have now been able to solve the problem (for me):

I log in to the app with the domain “gotify.domain.tld” and “igotify.domain.tld”. As a result, igotify naturally tries to resolve this DNS, the IP address behind it points to the NPM but with an IP address from my tailscale network, which the Docker container can't do anything with. I solved it as follows.

I added an alias to the network in the Docker Compose for my NPM:

networks:
  proxy:
    aliases:
      - gotify.domain.tld

This works as desired. Maybe this will help one or the other. As with Home Assistant and other projects, it would be best if you could overwrite the domain directly or via an env variable.

androidseb25 commented 3 weeks ago

Hi thx for you're solution, I working hard to solve the problem, at the moment I work on the app UI to make the config for the local docker network as simple as possible in Issue #59 you will find the progress. The iGotify Notification Container in the dev branch works currently very well in my dev environment.