Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IOS10 voipEnabled = true not work #309

Closed
hai00jiao opened this issue Feb 16, 2017 · 9 comments
Closed

IOS10 voipEnabled = true not work #309

hai00jiao opened this issue Feb 16, 2017 · 9 comments

Comments

@hai00jiao
Copy link

when my app enter background , the socket connection is paused, after the app enter foreground again, the request data arrive together.
UIBackgroundModes

voip
audio
fetch
remote-notification

@alphatroya
Copy link

Confirm, iOS 9 devices receive data normally, but iOS10 data receiving paused after going background. socket.voipEnabled enabled, background modes too.

There is any temporary workaround for this?

@alphatroya
Copy link

Fix it by launch background task in applicationDidEnterBackground method

@nitrag
Copy link

nitrag commented Mar 3, 2017

I don't think @alphatroya suggestion works, does it?

@Laptopmini
Copy link

Laptopmini commented Mar 28, 2017

FYI, using VOiP Background mode to keep the websocket connection alive goes against Apple TOS/Guidelines. It is a misuse of background modes, which is grounds for rejection from the AppStore.

@daltoniam
Copy link
Owner

Yeah I don't know why iOS 9 -> 10 caused this to stop working. That being said, @Laptopmini is right in general use cases. This was added for a very specific case of in house apps and someone using a WebSocket in a VOIP setup. I will try looking into this as time permits and PRs are welcomed.

@nitrag
Copy link

nitrag commented Mar 29, 2017

I've recently had an in-depth conversation with Apple DTS on this.

Simply, you have to use PushKit/APNS. The "Legacy VOIP API" as they call it (which would hand the socket over to the system to wake up your app if communication arrived) was deprecated in iOS 9 and removed in iOS 10. As such, there's no way to keep a socket connected while in the background and that flag no longer has any effect as OP described.

You can buy yourself ~3 min by launching a background task on applicationDidEnterBackground but that's all you get and it cannot be called again without the app entering the foreground (by the user).

@daltoniam nothing to look into I'm afraid, you should plan to pull the functionality.

@daltoniam
Copy link
Owner

@nitrag nice write up and thank you for that info! I'll do that next version (and update the documentation accordingly).

@sahara108
Copy link

If the app is woken up by the push notification, the socket will be closed after around 40 seconds with this error Socket being disconnect with error Optional(Error Domain=NSPOSIXErrorDomain Code=57 "Socket is not connected" UserInfo={_kCFStreamErrorCodeKey=57, _kCFStreamErrorDomainKey=1}). In my solutions, I will force the socket to re-connect when there is another push after socket being closed.

sahara108 added a commit to senagbe/Starscream that referenced this issue Jul 18, 2017
* 'master' of github.com:daltoniam/Starscream: (22 commits)
  updated podspec
  the joys of getting all the package manager to play nice
  Removed Else Clause that would sometimes give a wrong error message
  updated changelog
  updated pod spec for compression changes
  SecTrust object now is conditionally unwrapped
  spm fix
  spm fix
  package manager update
  fixes daltoniam#309, daltoniam#319, daltoniam#334
  make WSResponse values public
  Add Advanced Delegate and Custom HTTP methods
  Update README with (trite) grammar changes
  Include zlib as a module, rather than using `@_silgen_name` and redefinition.  This is less verbose and less error-prone.
  Add information about compression support to README.  Other changes based on PR feedback.
  Avoid unnecessary copying.  Confirm Autobahn fuzzing test results are comparable with the autobahn library itself.
  Fix capture memory leaks in Autobahn tester.
  Fixes to handle different windowsBits and noContextTakeover.
  Integrate compression classes.
  Add compression classes and unit tests.
  ...
@johnnynanjiang
Copy link

Hi @daltoniam one scenario I discovered is that

  1. websocket is connected in foreground, ping/pong going on
  2. websocket goes into background, ping/pong is paused
  3. websocket comes back to foreground, ping/pong continues for a short time
  4. websocket gets disconnected with error nil

Not sure if 4. is expected or not, can you please advise? Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants