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

Pass on supported gun opts in connect() #230

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

uwiger
Copy link

@uwiger uwiger commented May 6, 2020

This change allows users to pass on options supported by gun in a connect() call.

For example, this means that you can use alternative TLS port 2197 without gun guessing that you want TCP transport (add transport => tls), and you can set a longer keepalive than the default 5 seconds.

@ferigis
Copy link
Member

ferigis commented May 6, 2020

Hi Ulf,

Thanks a lot for your contribution, could you please fix the Travis complains? after that I will merge it for sure!

thanks

@elbrujohalcon
Copy link
Member

elbrujohalcon commented May 6, 2020

Just in case, @uwiger … the error that travis reports is:

The code in the following (LINE, COL) locations has the same structure: (237, 3), (251, 3).

It's an Elivs error that, unless you can abstract that code into something else that makes sense (probably not), you can "fix" by increasing min_complexity for the DRY rule in the elvis.config file.

@uwiger
Copy link
Author

uwiger commented May 6, 2020

@elbrujohalcon feels like cheating, but you're right - I couldn't easily come up with a refactoring that wouldn't be less readable than the existing code. :)

@codecov
Copy link

codecov bot commented May 6, 2020

Codecov Report

Merging #230 into master will decrease coverage by 0.56%.
The diff coverage is 66.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #230      +/-   ##
==========================================
- Coverage   87.55%   86.99%   -0.57%     
==========================================
  Files           7        7              
  Lines         217      223       +6     
==========================================
+ Hits          190      194       +4     
- Misses         27       29       +2     
Impacted Files Coverage Δ
src/apns_connection.erl 79.10% <66.66%> (-0.59%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f3aba9e...6724edc. Read the comment docs.

@uwiger
Copy link
Author

uwiger commented May 6, 2020

BTW, I noticed issue #205, which has been around for a while. Since gun defaults to sending keepalives every 5 seconds, I assume that the problem should be resolved. OTOH, a 5-second interval seems a bit eager for an APNs idle ping, right?

@uwiger
Copy link
Author

uwiger commented May 6, 2020

As I understand it, the code coverage is reduced due to the changes related to the proxy setup. There don't seem to be any proxy-related test cases in the connection_SUITE.

@uwiger
Copy link
Author

uwiger commented May 6, 2020

Since dialyzer run on the test code complained, I moved the gun options under a separate options key.

Copy link
Member

@elbrujohalcon elbrujohalcon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@elbrujohalcon
Copy link
Member

I guess we can safely ignore codecov… right, @ferigis?

Copy link
Member

@ferigis ferigis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, we will fix the coverage later

@essen
Copy link
Contributor

essen commented May 27, 2020

How did you get to a keepalive value of 10000? Trial and error? I'm looking into increasing the default to something more reasonable.

@uwiger
Copy link
Author

uwiger commented May 27, 2020

How did you get to a keepalive value of 10000? Trial and error? I'm looking into increasing the default to something more reasonable.

I only used 10 seconds in the test suite. I assumed that we might want to set the value to something much higher, but it's surprisingly hard to find some recommendation on the subject.

I found this article, which admittedly talks about a device being connected to APNS, but it makes sense that Apple shouldn't force mobile, battery-powered devices to ping at intervals of a few seconds.

When device is charging or enough battery, keep-alive is sent every 15-30 minutes.

there is of course also this...:

HTTP/2 ping is a terrible idea. The best we can hope for is that nobody uses it. That boat has sailed already though, as Apple is encouraging the PING frame use for checking the state of TCP connections to their APNS service.

@essen
Copy link
Contributor

essen commented May 27, 2020

Thanks.

I think the biggest improvement would be to make Gun NOT send the PING if there's been traffic sent or received in that time period. Then maybe set it to 1 minute by default, since there is no real power constraint. So Gun would by default send PING 1 minute after any data was sent or received.

To be honest there probably aren't too many people with mostly idle connections, so it might not make sense for it to be enabled by default. Not having it enabled would help avoid certain issues like too_many_pings. Having written all this I think this makes the most sense.

@paulo-ferraz-oliveira
Copy link
Contributor

paulo-ferraz-oliveira commented Oct 24, 2020

Is this not merged solely due to Travis CI complaints? Or is there something else missing? I read the whole thread and this seems good to go.

@ferigis

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

Successfully merging this pull request may close these issues.

5 participants