<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Akshet Pandey on Medium]]></title>
        <description><![CDATA[Stories by Akshet Pandey on Medium]]></description>
        <link>https://medium.com/@argetlam.akshet?source=rss-d23c06aa0840------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*SMPJ2iXKJsDBNszF.</url>
            <title>Stories by Akshet Pandey on Medium</title>
            <link>https://medium.com/@argetlam.akshet?source=rss-d23c06aa0840------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 19:25:38 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@argetlam.akshet/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Using HTTP3/QUIC with Cronet In Your Mobile App]]></title>
            <link>https://medium.com/the-react-native-log/using-cronet-in-your-mobile-app-7dda3a89c132?source=rss-d23c06aa0840------2</link>
            <guid isPermaLink="false">https://medium.com/p/7dda3a89c132</guid>
            <category><![CDATA[chromium]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[quic]]></category>
            <category><![CDATA[react-native]]></category>
            <dc:creator><![CDATA[Akshet Pandey]]></dc:creator>
            <pubDate>Sat, 31 Aug 2019 05:51:03 GMT</pubDate>
            <atom:updated>2019-09-02T12:02:10.644Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vzjky7wsR33VhQt30lKmvQ.png" /></figure><h4>Faster downloads, lower latencies, disconnect tolerance, now in your iOS/Android and react-native app!</h4><h3>Wait, there is an HTTP3?</h3><p>Currently in a <a href="https://quicwg.org/base-drafts/draft-ietf-quic-http.html">draft stage</a>, IETF and the <a href="https://quicwg.org/">QUIC working group</a> are working on finishing HTTP3 and the QUIC specification.</p><p>In the simplest of terms, HTTP3 is HTTP2 over QUIC.</p><h3>So what exactly is QUIC?</h3><p>QUIC is a network layer protocol implemented over UDP. Simply put, QUIC is an improvement over TCP. It provides much of what TCP does, i.e. a reliable network channel that handles losses, reordering, retransmission, and congestion control/fairness. On top of that, QUIC also provides:</p><ul><li>Dramatically reduced connection establishment time</li><li>Improved congestion control</li><li>Multiplexing without head of line blocking</li><li>Forward error correction</li><li>Connection migration</li></ul><p>This results in high performance in high latency channels, such as those on mobile devices. You can learn more about the advantages of using QUIC here:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FYWiRef3wOYY%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DYWiRef3wOYY&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FYWiRef3wOYY%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/dbd555096de067660b7fd040bbda6649/href">https://medium.com/media/dbd555096de067660b7fd040bbda6649/href</a></iframe><p>Here is my own test implemented in react-native to compare cronet performance on a high latency, low bandwidth channel.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*MZqU7IV12puAHYbtyrHopA.gif" /><figcaption>Left:OkHttp in React Native, Right: OkHttp + Cronet in React Native, both on a slow network with a QUIC capable server</figcaption></figure><h3>What is Cronet?</h3><p>The best description comes from the Cronet <a href="https://chromium.googlesource.com/chromium/src/+/master/components/cronet/README.md">README</a>:</p><blockquote>Cronet is the networking stack of Chromium put into a library for use on mobile. This is the same networking stack that is used in the Chrome browser by over a billion people. It offers an easy-to-use, high performance, standards-compliant, and secure way to perform HTTP requests. Cronet has support for both Android and iOS.</blockquote><p>Cronet is a very well implemented and tested¹ <a href="https://www.chromium.org/developers/design-documents/network-stack">network stack</a> that provides almost everything that a standard app needs from a network layer library, things like DNS, Cookies, SSL/TLS, HTTP(S), HTTP2, Proxy/PAC, OSCP, Websockets, and F̶T̶P̶ (soon to be removed). It also supports <strong>HTTP over </strong><a href="https://en.wikipedia.org/wiki/QUIC"><strong>QUIC</strong></a>, soon to be called <a href="https://en.wikipedia.org/wiki/HTTP/3"><strong>HTTP³</strong></a>². This makes it a very attractive library to use as the network layer for your mobile app.</p><h3>Who is using it?</h3><p>Cronet is used by <a href="https://developer.android.com/guide/topics/connectivity/cronet">Google Chrome, YouTube, Google App, Google Photos, and Maps — Navigation &amp; Transit.</a></p><p>HTTP3/QUIC is already being used or is in development by <a href="https://engineering.fb.com/android/building-zero-protocol-for-fast-secure-mobile-connections/">facebook</a> (<a href="https://github.com/facebookincubator/mvfst">mvfst</a>), <a href="https://eng.uber.com/employing-quic-protocol/">Uber</a>, <a href="https://cloudflare-quic.com/">Cloudflare</a>, <a href="https://www.fastly.com/blog/why-fastly-loves-quic-http3">Fastly</a>, most of <a href="https://cloudplatform.googleblog.com/2018/06/Introducing-QUIC-support-for-HTTPS-load-balancing.html">GCP Load Balancers and CDN</a> and many more, <a href="https://github.com/quicwg/base-drafts/wiki/Implementations">including Apple, Microsoft</a>, and <a href="https://github.com/mozilla/neqo">Mozilla</a>.</p><h3>How do I use QUIC in my app?</h3><p>The simplest way is to integrate cronet and have a backend server or CDN or a proxy like cloudflare that supports QUIC. Most google &amp; GCP services including Youtube support QUIC by default. Cloudflare, Akamai, and Fastly support QUIC but needs to be manually enabled.</p><h3>Using Cronet In Your App</h3><p>Based on whether your app is a native Android app, native iOS app or a react-native app, jump to the appropriate section.</p><h4>Using Cronet in Android</h4><p>If you are starting from scratch, using cronet as the network layer is documented on the <a href="https://developer.android.com/guide/topics/connectivity/cronet">android developer docs</a>. You can use it directly instead of using HttpUrlConnection or OkHttp.</p><p>It comes down to adding a library dependency in your build.gradle file.</p><pre>dependencies {<br>    implementation &#39;com.google.android.gms:play-services-cronet:16.0.0&#39;<br>} </pre><p>Then checking if cronet is available to use:</p><pre>CronetProviderInstaller.installProvider(reactContext).addOnCompleteListener(new OnCompleteListener&lt;Void&gt;() {<br>  @Override<br>  public void onComplete(@NonNull Task&lt;Void&gt; task) {<br>    if (task.isSuccessful()) {<br>      // Setup your code to use cronet here.<br>    }<br>  }<br>});</pre><p>After that follow the instructions to <a href="https://developer.android.com/guide/topics/connectivity/cronet/start#create">create an instance of the engine and send a request</a>.</p><h4>Using Cronet in Android using OkHttp</h4><p>If you already have an app, you are likely using OkHttp and very likely don’t want to rewrite every piece of code that interacts with the OkHttp API.</p><p>Fortunately, it is possible to use cronet with OkHttp. Follow the steps above and then, depending on what other libraries you use, follow one of the two steps below.</p><ol><li>If you are using <strong>Retrofit</strong>. You can use Retrofit.Builder.<a href="https://square.github.io/retrofit/2.x/retrofit/retrofit2/Retrofit.Builder.html#callFactory-okhttp3.Call.Factory-">callFactory</a> to pass in a custom call factory that you can write that works with cronet.</li></ol><p>An example implementation is available here: <a href="https://github.com/akshetpandey/react-native-cronet/blob/master/android/src/main/java/com/akshetpandey/rncronet/RNCronetOkHttpCall.java">RNCronetOkHttpCall.java</a></p><p>2. If you are <strong>NOT using Retrofit</strong>, you can use an OkHttp interceptor to make cronet work for you. This is a less ideal solution, but works mostly fine.</p><p>An example implementation is available here: <a href="https://github.com/akshetpandey/react-native-cronet/blob/master/android/src/main/java/com/akshetpandey/rncronet/RNCronetInterceptor.java">RNCronetInterceptor.java</a></p><p><em>Note: Though the files says RN, the code doesn’t use anything react-native specific.</em></p><h4>Using Cronet in iOS</h4><p>Although cronet works perfectly fine on iOS, it lacks substantial documentation. You can get started by reading <a href="https://chromium.googlesource.com/chromium/src/+/master/components/cronet/ios/Cronet.h">Cronet.h</a> and <a href="https://chromium.googlesource.com/chromium/src/+/master/components/cronet/ios/cronet_consumer/">cronet_consumer</a> sample code. However, once built, using cronet is much easier on iOS than Android.</p><p>Cronet is not officially available as a framework or cocoapod, but you can build it from source following the <a href="https://chromium.googlesource.com/chromium/src/+/master/components/cronet/ios/docs/BUILD.md">build instructions</a>. For your convenience, I have created a <a href="https://github.com/akshetpandey/Cronet.framework">podspec</a> that you can include:</p><pre>pod &#39;Cronet&#39;, &#39;78.0.3888.patch.0.pre&#39;</pre><p>After this you can initialize the engine and have <strong>NSURLSession</strong> and <strong>NSURLConnection</strong> use cronet internally. This is fairly straightforward to do:</p><pre>#include &lt;Cronet/Cronet.h&gt;</pre><pre>...</pre><pre>[Cronet setHttp2Enabled:YES];<br>[Cronet setQuicEnabled:YES];<br>[Cronet setBrotliEnabled:YES];<br>[Cronet setHttpCacheType:CRNHttpCacheTypeDisk];</pre><pre>[Cronet addQuicHint:@&quot;www.google.com&quot; port:443 altPort:443];</pre><pre>[Cronet start];</pre><pre>[Cronet registerHttpProtocolHandler];</pre><p>Sample code to get you started is here: <a href="https://github.com/akshetpandey/react-native-cronet/blob/master/example/ios/example/AppDelegate.m#L22-L33">AppDelegate.m</a></p><h4>Using Cronet in React Native</h4><p>I have made a <a href="https://github.com/akshetpandey/react-native-cronet">react-native library</a> that should make using cronet very simple. Just add it into your package.json</p><pre>yarn add react-native-cronet</pre><p>That is all you need to do for iOS.</p><p>On Android, you need to configure Fresco to also use it by adding the following in your <a href="https://github.com/akshetpandey/react-native-cronet/blob/master/example/android/app/src/main/java/com/example/MainApplication.java">MainApplication.java</a>. This depends on a <a href="https://github.com/react-native-community/cli/pull/653">PR waiting to be merged in react-native-community/cli</a>. In the meantime, you can use <a href="https://www.npmjs.com/package/patch-package">patch-package</a> with that patch.</p><pre>import com.akshetpandey.rncronet.RNCronetFrescoImagePipelineConfig;<br>import com.facebook.imagepipeline.core.ImagePipelineConfig;<br>import com.facebook.react.shell.MainPackageConfig;</pre><pre>public class MainApplication extends Application implements ReactApplication {</pre><pre>  private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {<br>    @Override<br>    protected List&lt;ReactPackage&gt; getPackages() {<br>      ImagePipelineConfig pipelineConfig = RNCronetFrescoImagePipelineConfig.build(getApplicationContext());<br>      MainPackageConfig config = new MainPackageConfig.Builder().setFrescoConfig(pipelineConfig).build();<br>      List&lt;ReactPackage&gt; packages = new PackageList(this, config).getPackages();<br>      // Packages that cannot be autolinked yet can be added manually here, for example:<br>      // packages.add(new RNCronetNetworkingPackage());<br>      return packages;<br>    }<br>  }<br>}</pre><p>¹- What is a better way to test a network stack than in Chrome, whose primary job is to fetch assets and data over the network and display them to the user?</p><p>²- QUIC is a general purpose transport layer network protocol built on top of UDP with a user space congestion control and packet loss recovery algorithm that is <a href="https://datatracker.ietf.org/wg/quic/documents/">still being improved</a>. HTTP3 is an application layer protocol that speaks HTTP over QUIC.</p><h3>Hire Me</h3><p>I am looking for new opportunities, you can learn more about me on <a href="https://www.linkedin.com/in/akshet/">LinkedIn</a> and see more of my work on <a href="https://github.com/akshetpandey">GitHub</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7dda3a89c132" width="1" height="1" alt=""><hr><p><a href="https://medium.com/the-react-native-log/using-cronet-in-your-mobile-app-7dda3a89c132">Using HTTP3/QUIC with Cronet In Your Mobile App</a> was originally published in <a href="https://medium.com/the-react-native-log">The React Native Log</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>