Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Jul 21, 2025. It is now read-only.

Conversation

@erikjohnston
Copy link
Member

After start_tls we need to manually call connection_made on the protocol to tell it about the new underlying transport. This gives a brief window where the protocol can receive data without having a transport to write to, causing issues with the APNS connections where it assumes it can write once it starts reading data.

We fix this by wrapping the protocol in a buffer that simply buffers incoming data until connection_made is called.

Fixes #167, hopefully

@erikjohnston erikjohnston changed the title Fix race when using HTTPS proxy. Fix race when using HTTP proxy. Mar 19, 2021
After `start_tls` we need to manually call `connection_made` on the
protocol to tell it about the new underlying transport. This gives a
brief window where the protocol can receive data without having a
transport to write to, causing issues with the APNS connections where it
assumes it can write once it starts reading data.

We fix this by wrapping the protocol in a buffer that simply buffers
incoming data until `connection_made` is called.
@erikjohnston erikjohnston force-pushed the erikj/fix_https_race branch from f5e5bed to f368852 Compare March 19, 2021 17:15
@erikjohnston erikjohnston force-pushed the erikj/fix_https_race branch from 5a3ef74 to e66c744 Compare March 19, 2021 17:28
@erikjohnston erikjohnston requested a review from a team March 19, 2021 17:31
Copy link
Member

@clokep clokep left a comment

Choose a reason for hiding this comment

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

I don't really see how this is happening (maybe the Twisted reactor is stealing control during the await?) Seems like this should fix the issue though.

@erikjohnston
Copy link
Member Author

I don't really see how this is happening (maybe the Twisted reactor is stealing control during the await?) Seems like this should fix the issue though.

It's possible there's just a lot of work queued up, or a GC happens, or some TLS session resumption that allows the server to send data immediately, or... something. I don't really know :/

@erikjohnston erikjohnston merged commit 72ff6c5 into master Mar 22, 2021
@erikjohnston erikjohnston deleted the erikj/fix_https_race branch March 22, 2021 09:51
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Using a HTTP proxy sometimes breaks TLS connections

2 participants