element-hq / synapse

Synapse: Matrix homeserver written in Python/Twisted.
https://element-hq.github.io/synapse
GNU Affero General Public License v3.0
1.05k stars 123 forks source link

[bug] no calling notfication when using own ntfy push server #17269

Open warioishere opened 1 month ago

warioishere commented 1 month ago

Description

Hey, since a year I am having an issue that calling notifications dont work when using a own ntfy push server with our own matrix synapse server instance. Message notifications do work generally but as know by others not really reliable and with huge delays sometimes Using an matrix.org with our own ntfy server do work , both on messages and both on calls. We use a own coturnserver, I just switched from letsencrypt certs to zerossl certs as somebody suggested.

Still, we dont get call notifications to work. With Letsencrypt certs. nothing happens. With zerossl certs, elements crashes after opening the phone after a not notified call. I have been searching for almost a year now and nobody can help. I checked ntfy docks, checked with the devs there, my ntfy server seems to work. Also because it works with matrix.org servers.

This is the logs from element-android:

type: crash
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

This is the issue I openend on element-android to see more details:

https://github.com/element-hq/element-android/issues/8761

I would be sooo happy to get this to work after months and almost years of trying. I always hoped, gonna be fixed with new synapse Versions. But not, nothing fixes our issue.

We are on latest synapse version, and latest f-droid element version

Thanks in advance

Steps to reproduce

Calling on matrix.org account with own ntfy server works, we get call notification Calling on our own matrix instance (matrix.yourdevice.ch) doesnt work, no notification

Homeserver

matrix.yourdevice.ch

Synapse Version

{"server_version":"1.108.0"}

Installation Method

Debian packages from packages.matrix.org

Database

PostgresSQL

Workers

Single process

Platform

Ubuntu Server 22.04 virtualized on proxmox 8.2.2

Configuration

no

Relevant log output

type: crash
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

Anything else that would be useful to know?

No response

warioishere commented 1 month ago

additional info, our coturn server should work without problems:

turnutils_uclient -p 5349 -W xyz -v -y coturn.mydomain.ch
0: : IPv4. Connected from: 192.168.1.84:39630
0: : IPv4. Connected from: 192.168.1.84:39630
0: : IPv4. Connected to: 82.165.65.57:5349
0: : allocate sent
0: : allocate response received: 
0: : allocate sent
0: : allocate response received: 
0: : success
0: : IPv4. Received relay addr: 82.165.65.57:56644
0: : clnet_allocate: rtv=14186039741895531052
0: : refresh sent
0: : refresh response received: 
0: : success
0: : IPv4. Connected from: 192.168.1.84:34058
0: : IPv4. Connected to: 82.165.65.57:5349
0: : IPv4. Connected from: 192.168.1.84:33738
0: : IPv4. Connected to: 82.165.65.57:5349
0: : IPv4. Connected from: 192.168.1.84:45996
0: : IPv4. Connected to: 82.165.65.57:5349
0: : IPv4. Connected from: 192.168.1.84:49300
0: : IPv4. Connected to: 82.165.65.57:5349
0: : allocate sent
0: : allocate response received: 
0: : allocate sent
0: : allocate response received: 
0: : success
0: : IPv4. Received relay addr: 82.165.65.57:56645
0: : clnet_allocate: rtv=0
0: : refresh sent
0: : refresh response received: 
0: : success
0: : allocate sent
0: : allocate response received: 
0: : allocate sent
0: : allocate response received: 
0: : success
0: : IPv4. Received relay addr: 82.165.65.57:55852
0: : clnet_allocate: rtv=6301046898216256877
0: : refresh sent
0: : refresh response received: 
0: : success
0: : allocate sent
0: : allocate response received: 
0: : allocate sent
0: : allocate response received: 
0: : success
0: : IPv4. Received relay addr: 82.165.65.57:55853
0: : clnet_allocate: rtv=0
0: : refresh sent
0: : refresh response received: 
0: : success
0: : allocate sent
0: : allocate response received: 
0: : allocate sent
0: : allocate response received: 
0: : success
0: : IPv4. Received relay addr: 82.165.65.57:58186
0: : clnet_allocate: rtv=5524863492269791289
0: : refresh sent
0: : refresh response received: 
0: : success
0: : channel bind sent
1: : cb response received: 
1: : success: 0x5b52
1: : channel bind sent
1: : cb response received: 
1: : success: 0x5a83
1: : channel bind sent
1: : cb response received: 
1: : success: 0x4cb1
1: : channel bind sent
1: : cb response received: 
1: : success: 0x7375
1: : Total connect time is 1
1: : start_mclient: msz=4, tot_send_msgs=0, tot_recv_msgs=0, tot_send_bytes ~ 0, tot_recv_bytes ~ 0
2: : start_mclient: msz=4, tot_send_msgs=0, tot_recv_msgs=0, tot_send_bytes ~ 0, tot_recv_bytes ~ 0
3: : start_mclient: msz=4, tot_send_msgs=0, tot_recv_msgs=0, tot_send_bytes ~ 0, tot_recv_bytes ~ 0
4: : start_mclient: msz=4, tot_send_msgs=10, tot_recv_msgs=10, tot_send_bytes ~ 1000, tot_recv_bytes ~ 1000
5: : start_mclient: msz=4, tot_send_msgs=10, tot_recv_msgs=10, tot_send_bytes ~ 1000, tot_recv_bytes ~ 1000
6: : start_mclient: msz=4, tot_send_msgs=15, tot_recv_msgs=15, tot_send_bytes ~ 1500, tot_recv_bytes ~ 1500
6: : done, connection 0x740d1c77d010 closed.
6: : done, connection 0x740d1c75c010 closed.
6: : done, connection 0x740d1c73b010 closed.
6: : done, connection 0x740d1c71a010 closed.
7: : start_mclient: tot_send_msgs=20, tot_recv_msgs=20
7: : start_mclient: tot_send_bytes ~ 2000, tot_recv_bytes ~ 2000
7: : Total transmit time is 6
7: : Total lost packets 0 (0.000000%), total send dropped 0 (0.000000%)
7: : Average round trip delay 35.700000 ms; min = 31 ms, max = 39 ms
7: : Average jitter 2.000000 ms; min = 0 ms, max = 5 ms
warioishere commented 1 month ago

can someone of the devs maybe just give an answer on this issue, its been ages that this persists and noone is getting an answer. I was supporting matrix developtment with donations from time to time and my opinion ist hat the matrix-synapse is very important for a free and independent messaging communication system worldwide. I am just slowly pissed that this this important topic is not getting any attention anymore.

Why do you guys just leave every topic behind that is pointing at this thing. Why do you devs just keep low on that? Do you want us to use google's FCM so they know whom we are in contact with? Maybe you can give people a little hint on whats going on we are staying motivated. I slowly drop my interesst if this persists.

warioishere commented 1 month ago

unbelieveable that still noone of the whole matrix team can leave a comment here. I will definitly stop my monthly donations and start looking to put my effort on a messenger system with working notifications

S7evinK commented 5 days ago

According https://developer.android.com/develop/background-work/services/foreground-services#background-start-restriction-exemptions, a background service is not allowed to start a foreground service. There may be workarounds, but that would need to be implemented in Element Android.

I'm surprised that it works when using a matrix.org server, can you double check it is indeed using your ntfy server?

Element Android is unfortunately in maintenance mode and only receiving security fixes. In the mean time, you can try using Element X Android. Unfortunately, that means setting up the Sliding Sync Proxy (at the time of writing), but Synapse is getting a native implementation soon as well.