twilio / conversations-ios

SPM releases
https://www.twilio.com/docs/conversations/ios/changelog
10 stars 5 forks source link

Conversations v1.2.0 fails to reconnect when resuming from background #3

Closed tomhut closed 3 years ago

tomhut commented 3 years ago

Hi,

I've been running into a strange issue since upgrading to conversations v1.2.0. When my application comes to the foreground, after being backgrounded for 15-30mins occasionally the conversations client ends up in a state where no messages can be sent or received. I can reproduce the issue somewhat reliably with the kickstart project, using a long lived (23 hour) token to ensure the problem wasn't related to an expired token or my app.

Steps to reproduce: 1) Clone the kickstart project: https://github.com/TwilioDevEd/conversations-quickstart-swift 2) Follow the setup instructions in the readme, the only change I made was to change the lifespan of the token to 23 hours. 3) Compile the app and deploy it to a device. At this point I disconnect the device from my computer to ensure Xcode isn't keeping the app awake. 4) Launch the app. 5) Lock the screen, wait 30 mins. 6) Unlock the device, try to send a message.

If the message sends, force quit the app and relaunch it, trying steps 4-6 again. Perhaps 1/10 times it will fail.

I have reproduced this on iOS 13.7 and 14.4. The only way to get the client to reconnect is to force quit the app. I have been unable to reproduce this using the previous release of the conversations SDK so far.

Gray-Wind commented 3 years ago

HI, thank you for reporting, I will take a look at this issue ASAP.

mweyamutsvene commented 3 years ago

Im seeing this issue too. Occasionally the sdk will auto reconnect, but 80% of the time it gets stuck and all api calls timeout. I can usually reproduce this after being in background for 30 seconds.

Gray-Wind commented 3 years ago

We are working on this issue, I will post an update soon.

tomhut commented 3 years ago

@Gray-Wind Thanks, let me know if you would like any logs etc.

Gray-Wind commented 3 years ago

Hello,

This issue was fixed in the latest release 1.3.0. Please note, that current version couldn't be distributed with Carthage, because of its limitations. But we've added SPM support.

aiyub007 commented 3 years ago

i checked the same using 1.3.0 it again fails to reconnect when keeping app background for 5-10 mins and come to background it enable to reconnect the console is : [connection] nw_read_request_report [C28] Receive failed with error "Software caused connection abort"

Gray-Wind commented 3 years ago

Please collect logs from SDK (by setting TwilioConversationsClient.setLogLevel(.trace)) with reproduction and send them to the new support ticket or to this email address: ikolomeitsev@twilio.com.

aiyub007 commented 3 years ago

Hi Gray-wind

After coming from background to forground when i check

Syncronization status : true
Connection status : false
Trying to reconnect
Syncronization status : true
Connection status : true
Getting msgs 

In getting msgs when i am calling..

currentConversationObj.getLastMessages(withCount: 20) { (result, msgs) in
                    self.manageObj(result: result, msgs: msgs ?? [])
            }

control just stay inside for 4-5 seconds and then gave

result.isSuccessful > false and
error > ""

when i call getConversation again then it works fine [so first time after disconnected i tried to connect and then i got empty msgs list]

Gray-Wind commented 3 years ago

Turned out that client was re-created on return from background. And in some other occasions.