element-hq/element-android

no call notification when using own ntfy server

warioishere opened this issue · 20 comments

Steps to reproduce

Hello,

I am encountering an issue with call notifications not working when using a custom ntfy server. When selecting Google Push for notifications, both call notifications and the ringtone work as expected. However, switching to a custom ntfy server, the call notifications fail to come through, although message notifications continue to work without issue.

This problem persists across the following setup:

  • Matrix-synapse version: v1.101.0 (Latest)
  • Element version on smartphone: 1.6.10

Additionally, if relevant, a custom coturn server has been set up for handling phone and video calls.
Same problem on different phone. Had a p7 Pro with calyx + micro-G before, now having a P8Pro with GrapheneOS, same Problem again.

Could there be a compatibility issue with the custom ntfy server, or is there a specific configuration I might be missing to enable call notifications through it? Any guidance or suggestions on troubleshooting this issue would be greatly appreciated.

Thank you for your assistance.

Outcome

What did you expect?

Calling notification works on external ntfy server

What happened instead?

No ringing at all

Your phone model

Pixel 8 Pro

Operating system version

Android 14 GrapheneOS latest

Application version and app store

No response

Homeserver

f-Droid 1.6.10

Will you send logs?

Yes

Are you willing to provide a PR?

Yes

Additional info. I've been talking to ntfy devs and we checked the server deployment of mine, they say my server setup is correct. They said I should reach out to the devs of element on android. Also, it doesnt work with the public ntfy.sh server.
Calls do not get a notfication, message notfications work fine.

Greetings

It may be related to this: https://matrix-org.github.io/synapse/latest/usage/configuration/config_documentation.html#ip_range_whitelist

thanks, just tried this. Added my own push server to the whitelisted IP adresses.

Still not luck. Element on Desktop Linux works, it rings. Phone doesnt want to ring when using own push server.

Sad no one of the devs answers me on this.

#7069 (comment) follow those steps

Again, I am not having problems receiving notifications at all. Messages notifications do arrive. Also the Push Test on element is sucessful. They only thing i missed was the IP whitelisting, but still, the notifications worked because of some firewall settings I have.

The only thing that doesnt work, are call notifications. I dont get notification if someone calls me. Nothing happens, only if I open the app, the call rings. If the app is closed. No ringing, allthough Element passes the Push test, and message notifications do arrive.

I checked those steps you linked to me, but no sucess.

  1. Have you disabled battery optimization for Element ?
  2. Have you disabled any kind of notification in Android settings ?
  3. Can you get some logs using ADB:
    1. Set Element in the background
    2. Send a message to this client
    3. Start a call
  1. Have you disabled battery optimization for Element ?

    1. Have you disabled any kind of notification in Android settings ?

    2. Can you get some logs using ADB:

      1. Set Element in the background
      2. Send a message to this client
      3. Start a call
  1. Bat Optimization is off for ntfy
  2. No, didnt disable any kind of notification on Android
  3. If your would tell me what to do, I can provide logs, I have ADB installed, but need some short instructions if you have time :)
  1. I was talking about battery optimization for Element.
  2. Please check, I've already seen someone who thought nothing were changed but the notification channel was mute
  3. Of course, here you are: PID=$(adb shell pidof im.vector.app) && adb logcat --pid $PID
  1. I was talking about battery optimization for Element.

    1. Please check, I've already seen someone who thought nothing were changed but the notification channel was mute

    2. Of course, here you are: PID=$(adb shell pidof im.vector.app) && adb logcat --pid $PID

what do you mean by channel notifications? All notifications on Android settings notification wise are allowed for the app. Also i get loud notfication on messages.

I will check battery optimiztions on element later. Just curious why I should disable it as it didnt read anything about disabling bat optimizations when own push servers are used.

Using googles push services makes the phone ring. Also on battery optimization activated on element.

Ill check the logs on element later or tomorrow with my gf

thanks in advance :)

I confirm I have the same issue as @warioishere
I have a very similar configuration with self hosted Synapse server, with self hosted ntfy server.
I also get normal messages notification, but no call notification on my phone without google services, relying on unified push for notifications.

I have to verify but it looks as if other users on my Synapse server wich are using Android with google notification also gets messages notifications but not call notification

Looks similar to #8428 and #7135

I can just tell that the matrix server can reach the ntfy server and everytime I get a message server, I get this on my matrix logs:

2024-05-19 14:47:47,711 - synapse.push.httppusher - 236 - INFO - httppush.process-293 - Processing 0 unprocessed push actions for @marioyd:matrix.yourdevice.ch/im.vector.app.android/https://ntfy.yourdevice.ch/upuTdBfWrtUslO?up=1 starting at stream_ordering 1317362

when someone calls me, there is no log like this. I didnt check the element logs yet, sorry

Here is what I tried : in element by default in the general notification settings, "messages sent by robots" is disable. I enabled it, I will see if this resolve the problem

I can just tell that the matrix server can reach the ntfy server and everytime I get a message server, I get this on my matrix logs:

2024-05-19 14:47:47,711 - synapse.push.httppusher - 236 - INFO - httppush.process-293 - Processing 0 unprocessed push actions for @marioyd:matrix.yourdevice.ch/im.vector.app.android/https://ntfy.yourdevice.ch/upuTdBfWrtUslO?up=1 starting at stream_ordering 1317362

when someone calls me, there is no log like this. I didnt check the element logs yet, sorry

That's interesting, can you try your exact same setup with an account on matrix.org ? There might be something with synapse then

That's interesting, can you try your exact same setup with an account on matrix.org ? There might be something with synapse then

yes, I'll try later. I can imagine that its actually a synapse problem, because it doesnt work n schildichat too, although its a fork I guess and it could have a similar issue.

Will let you know

I can just tell that the matrix server can reach the ntfy server and everytime I get a message server, I get this on my matrix logs:

2024-05-19 14:47:47,711 - synapse.push.httppusher - 236 - INFO - httppush.process-293 - Processing 0 unprocessed push actions for @marioyd:matrix.yourdevice.ch/im.vector.app.android/https://ntfy.yourdevice.ch/upuTdBfWrtUslO?up=1 starting at stream_ordering 1317362

when someone calls me, there is no log like this. I didnt check the element logs yet, sorry

That's interesting, can you try your exact same setup with an account on matrix.org ? There might be something with synapse then

sorry for this late answer. Tested on matrix.org with my own ntfy server. It works instantly. Getting Call notification.
I it looks like its my matrix instance. But I dont know what to check for or change in homeserver.yml
Do you you have any hint on that?

Additional Info: we are using our own coturn server. Are there things or additional configs needed to be done there?

Additional Info, we are using a Letsencrypt Certificate from letsencrypt for the coturn server, there was once a coturn tester for matrix instances, but I cant find it anymore. It said that time ago that the setup was functional. Now i read this again:

NB: If your TLS certificate was provided by Let's Encrypt, TLS/DTLS will not work with any Matrix client that uses Chromium's WebRTC library. This currently includes Element Android & iOS; for more details, see their [respective](https://github.com/element-hq/element-android/issues/1533) [issues](https://github.com/element-hq/element-ios/issues/2712) as well as the underlying [WebRTC issue](https://bugs.chromium.org/p/webrtc/issues/detail?id=11710). Consider using a ZeroSSL certificate for your TURN server as a working alternative.

Could be the issue?

I changed to ZeroSSL Certificates, now Element Crashes after Calling the phone with my own matrix-synapse instance:

osVersion: google/husky/husky:14/AP1A.240505.005/2024053100:user/release-keys
package: im.vector.app:40106142
process: im.vector.app
processUptime: 55946 + 249 ms
installer: org.fdroid.fdroid

java.lang.RuntimeException: Unable to start service im.vector.app.core.services.CallAndroidService@b58b5ec with Intent { act=im.vector.app.core.services.CallService.ACTION_CALL_TERMINATED cmp=im.vector.app/.core.services.CallAndroidService (has extras) }: android.app.ForegroundServiceStartNotAllowedException: Service.startForeground() not allowed due to mAllowStartForeground false: service im.vector.app/.core.services.CallAndroidService
	at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:5079)
	at android.app.ActivityThread.-$$Nest$mhandleServiceArgs(Unknown Source:0)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2397)
	at android.os.Handler.dispatchMessage(Handler.java:107)
	at android.os.Looper.loopOnce(Looper.java:232)
	at android.os.Looper.loop(Looper.java:317)
	at android.app.ActivityThread.main(ActivityThread.java:8532)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
	at com.android.internal.os.ExecInit.main(ExecInit.java:50)
	at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
	at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:359)
Caused by: android.app.ForegroundServiceStartNotAllowedException: Service.startForeground() not allowed due to mAllowStartForeground false: service im.vector.app/.core.services.CallAndroidService
	at android.app.ForegroundServiceStartNotAllowedException$1.createFromParcel(ForegroundServiceStartNotAllowedException.java:54)
	at android.app.ForegroundServiceStartNotAllowedException$1.createFromParcel(ForegroundServiceStartNotAllowedException.java:50)
	at android.os.Parcel.readParcelableInternal(Parcel.java:5035)
	at android.os.Parcel.readParcelable(Parcel.java:5017)
	at android.os.Parcel.createExceptionOrNull(Parcel.java:3186)
	at android.os.Parcel.createException(Parcel.java:3175)
	at android.os.Parcel.readException(Parcel.java:3151)
	at android.os.Parcel.readException(Parcel.java:3093)
	at android.app.IActivityManager$Stub$Proxy.setServiceForeground(IActivityManager.java:6876)
	at android.app.Service.startForeground(Service.java:878)
	at androidx.work.impl.foreground.SystemForegroundService$Api29Impl$$ExternalSyntheticApiModelOutline0.m(R8$$SyntheticClass:1)
	at im.vector.app.core.extensions.ServiceKt.startForegroundCompat(Service.kt:31)
	at im.vector.app.core.extensions.ServiceKt.startForegroundCompat$default(Service.kt:6)
	at im.vector.app.core.services.CallAndroidService.handleUnexpectedState(CallAndroidService.kt:55)
	at im.vector.app.core.services.CallAndroidService.handleCallTerminated(CallAndroidService.kt:89)
	at im.vector.app.core.services.CallAndroidService.onStartCommand(CallAndroidService.kt:98)
	at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:5061)
	... 11 more

I changed to ZeroSSL Certificates, now Element Crashes after Calling the phone with my own matrix-synapse instance:

osVersion: google/husky/husky:14/AP1A.240505.005/2024053100:user/release-keys
package: im.vector.app:40106142
process: im.vector.app
processUptime: 55946 + 249 ms
installer: org.fdroid.fdroid

java.lang.RuntimeException: Unable to start service im.vector.app.core.services.CallAndroidService@b58b5ec with Intent { act=im.vector.app.core.services.CallService.ACTION_CALL_TERMINATED cmp=im.vector.app/.core.services.CallAndroidService (has extras) }: android.app.ForegroundServiceStartNotAllowedException: Service.startForeground() not allowed due to mAllowStartForeground false: service im.vector.app/.core.services.CallAndroidService
	at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:5079)
	at android.app.ActivityThread.-$$Nest$mhandleServiceArgs(Unknown Source:0)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2397)
	at android.os.Handler.dispatchMessage(Handler.java:107)
	at android.os.Looper.loopOnce(Looper.java:232)
	at android.os.Looper.loop(Looper.java:317)
	at android.app.ActivityThread.main(ActivityThread.java:8532)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
	at com.android.internal.os.ExecInit.main(ExecInit.java:50)
	at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
	at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:359)
Caused by: android.app.ForegroundServiceStartNotAllowedException: Service.startForeground() not allowed due to mAllowStartForeground false: service im.vector.app/.core.services.CallAndroidService
	at android.app.ForegroundServiceStartNotAllowedException$1.createFromParcel(ForegroundServiceStartNotAllowedException.java:54)
	at android.app.ForegroundServiceStartNotAllowedException$1.createFromParcel(ForegroundServiceStartNotAllowedException.java:50)
	at android.os.Parcel.readParcelableInternal(Parcel.java:5035)
	at android.os.Parcel.readParcelable(Parcel.java:5017)
	at android.os.Parcel.createExceptionOrNull(Parcel.java:3186)
	at android.os.Parcel.createException(Parcel.java:3175)
	at android.os.Parcel.readException(Parcel.java:3151)
	at android.os.Parcel.readException(Parcel.java:3093)
	at android.app.IActivityManager$Stub$Proxy.setServiceForeground(IActivityManager.java:6876)
	at android.app.Service.startForeground(Service.java:878)
	at androidx.work.impl.foreground.SystemForegroundService$Api29Impl$$ExternalSyntheticApiModelOutline0.m(R8$$SyntheticClass:1)
	at im.vector.app.core.extensions.ServiceKt.startForegroundCompat(Service.kt:31)
	at im.vector.app.core.extensions.ServiceKt.startForegroundCompat$default(Service.kt:6)
	at im.vector.app.core.services.CallAndroidService.handleUnexpectedState(CallAndroidService.kt:55)
	at im.vector.app.core.services.CallAndroidService.handleCallTerminated(CallAndroidService.kt:89)
	at im.vector.app.core.services.CallAndroidService.onStartCommand(CallAndroidService.kt:98)
	at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:5061)
	... 11 more

I am having the exact same problem. With background synchronization as the notification method, it works great (although not always instantly), but at least call notifications work sometimes. However, if I use ntfy, it crashes when an incoming call is received, throwing the exact same error as @warioishere described. I think this might be related to the fact that Element is trying to do something with foreground services, but it isn't allowed (since it is not using that method). I can help with debugging this if you think my theory might be correct.