ChatSecure / ChatSecure-iOS

ChatSecure is a free and open source encrypted chat client for iOS that supports OTR and OMEMO encryption over XMPP.
https://chatsecure.org
Other
3.13k stars 1.03k forks source link

Push Messaging not registering #883

Open RoundOrange opened 7 years ago

RoundOrange commented 7 years ago

Hi

I am unable to get ChatSecure to register for push notifications. I have reviewed other issues, but from what I can tell, most are about push as least trying to register but not working. In my case, the app will not register for push notifications.

My Setup:

What happens: When I open "Server Information" for the account. I see the loading symbol for "Push Registration" and a green tick for "Push". Very quickly, both symbols change to a yellow warning symbol and the message "Device Not Registered" appears in the "Push Registration" section. Is this message referring to https://push.chatsecure.org/api/v1/ or prosody?

In the prosody logs, I do not see a request to enable push notification from the device. No attempt is made to connect to any chatsecure.org servers. Does the registration process require any open ports on the prosody server other than the usual c2s & s2s ports (if any at all)?

I suspect that the information provided at https://push.chatsecure.org/api/v1/ is about the API and that I don't need to manually create an account there. Is this correct?

On the iPhone, Background App Refresh is enabled and all Notification options are enabled for ChatSecure. Low Power Mode is off. Any other settings I should check? I have tried Logout/Login, restarting the phone, reinstalling the app.

Any assistance will be appreciated. Thanks.

chrisballinger commented 7 years ago

Wow thanks for the very detailed issue, you definitely did your homework. :) Based on everything you've mentioned it should be working and my personal server setup is almost identical.

The basic push flow is this:

  1. iOS client sends the device's APNS push token to https://push.chatsecure.org/api/v1/ (making an account if needed).
  2. If step 1 succeeds... iOS client sends "pubsub.chatsecure.org", random rotating token provided by push.chatsecure.org/api, and the "push.chatsecure.org/api" endpoint itself, to your XMPP server. Our pubsub node does server-to-server communication with your own server.
  3. When you're offline your server will use mod_cloud_notify to lookup "pubsub.chatsecure.org" and send an XMPP packet to that server containing the random token from (2), as well as "push.chatsecure.org/api".
  4. pubsub.chatsecure.org receives API endpoint ("push.chatsecure.org/api") and random token, constructs HTTP POST request, and fires it off.
  5. "push.chatsecure.org/api" receives the POST and extracts random token, then looks up your account, and then looks up your APNS push token. Then it sends a push message to Apple.

It looks like you're having issues with step 1, but possibly step 2 as well. If you don't see any logs from mod_cloud_notify then it's probably failing on step 1. What happens when you try the "Reset..." button on the info screen with the warning?

RoundOrange commented 7 years ago

Based on the push flow, I also suspect the problem is at step 1. The only thing in the prosody logs for cloud_notify is "Module Loaded" so I don't think I am getting to step 2.

Tapping reset will send the below disable request, but the app never sends an enable request.

<iq type="set" id="ABCDABCD-ABCD-ABCD-ABCD-ABCDABCD"><disable xmlns="urn:xmpp:push:0" jid="pubsub.chatsecure.org"/></iq>

When tapping Reset, a packet trace shows:

  1. XMPP+TLS packets to/from prosody (disable request/reply)
  2. DNS lookup for push.chatsecure.org
  3. HTTPS session to push.chatsecure.org (maybe 2 or 3 requests in that session)
  4. No traffic to prosody after the HTTPS session

Looking at the device console in XCode I can see the following message:

ChatSecure(libswiftFoundation.dylib)[277] <Notice>: Unable to register this device

It appears that the app is failing to register the device with push.chatsecure.org. Any ideas what would cause this or how I can debug it further?

chrisballinger commented 7 years ago

Wait, are you running this in the Xcode Simulator or on an actual device? The only way push registration will work is if you run the official App Store or TestFlight builds on a real device.

RoundOrange commented 7 years ago

The device is a real iPhone 8 with the app installed from the App Store. The log message is from the device console in "Devices and Simulators" with the iPhone connected by cable, not a debug run.

chrisballinger commented 7 years ago

Hm. There shouldn't be logs shown at all because we disable logging for production builds, perhaps one snuck through using NSLog or something.

Could you try uninstalling and reinstalling the app?

RoundOrange commented 7 years ago

I have:

  1. Uninstalled the app
  2. Rebooted the phone
  3. Installed the app from the App Store (version 4.2.1)
  4. Setup the account with 'Add Existing Account'
  5. Tapped 'Enable Push'
  6. Allow Notifications
  7. Tapped 'Push Warning' at the bottom of the screen
  8. "Device Not Registered" message shows

Trying a reset again only repeated what I reported earlier (disable sent to prosody, but not enable).

At no time did an enable request get sent to prosody (I currently have the rawdebug plugin installed).

Does step 1 in the push flow rely on any configuration on my prosody server or DNS, or does it only involve the device, your server and Apple?

chrisballinger commented 7 years ago

Step 1 relies just on the device, Apple, and our push API server.

RoundOrange commented 6 years ago

I have tested again with iOS 11.2 and the issue continues. I have also tried the user's iPad and get the same problem.

chrisballinger commented 6 years ago

Do any other apps work with push notifications? Are they signed in with an Apple ID? I've never seen this before except in the iOS simulator where Apple's push notification APIs don't work.

RoundOrange commented 6 years ago

I got a 7 day trial from https://pushover.net/ and was able to successfully send a message to the iPhone. Both iPhone and iPad are signed in with the same Apple account. I have reinstalled ChatSecure again and it still fails with the message "Device Not Registered".

chrisballinger commented 6 years ago

Very strange...

Can you access https://push.chatsecure.org/api/v1/ from Safari on the affected device?

RoundOrange commented 6 years ago

Yes, I can access that URL from both devices. I have tried a different Apple ID on the phone (that was fun) and nothing changed. I also tried the iPad with personal hotspot and got the same problem.

User001111 commented 6 years ago

Me and my friends have the same issue since last friday, used CS for a long time no issues untill last friday. We all have the same issue; XEP0357 push error. I’ve tried other server providers and the issue stay or with a couple other i cant even register my account it says: Cant connect to Xmpp server. The servers that do register all show XEP 0357 error I’ve tried almost everything, re-install the app, reboot, other servers, reset push.

antonyablonsky commented 6 years ago

@RoundOrange how did you connect pushover?

RoundOrange commented 6 years ago

@antonyablonsky Unfortunately I was never able to resolve this issue. If you are affected by this issue, there is nothing you can do. It appears to be a problem between ChatSecure's push messaging servers and Apple's servers. It could be an iOS bug.

chrisballinger commented 6 years ago

@RoundOrange There is plenty you can do! You should install the latest version of mod_cloud_notify on your server and use:

push_notification_important_body = "New Message!"

If you don't enable that option, pushes will not pass through to your devices.

RoundOrange commented 6 years ago

@chrisballinger I don't get that far. My prosody server never receives a push token from the device. Registering for push messaging fails at the first step. I don't see how upgrading the server will help if it never receives the token in the first place.

chrisballinger commented 6 years ago

You might want to try again. I made some major improvements to server capacity on Saturday.

RoundOrange commented 6 years ago

I have retested again and the "Device Not Registered" message remains.

Echolon commented 6 years ago

Hi,

just started an EtherCalc Pad to collect information about your and others experience about push. Feel free to add your data or additional columns (suggest only to add columns where the information can be given from a normal user)

https://ethercalc.org/29iyo1nunqdp

Cheers

licaon-kter commented 6 years ago

I just installed/reinstalled for some users and (at least) after account setup, push stays "unregistered".

I guessed that I might need to send some messages first, but I forgot to check.