{"id":15107824,"url":"https://github.com/vkcom/knet","last_synced_at":"2026-01-14T02:10:55.251Z","repository":{"id":45706229,"uuid":"407564319","full_name":"VKCOM/KNet","owner":"VKCOM","description":"Android network library with QUIC protocol supporting.","archived":true,"fork":false,"pushed_at":"2022-01-24T15:02:17.000Z","size":17428,"stargazers_count":151,"open_issues_count":3,"forks_count":22,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-01-17T17:42:21.506Z","etag":null,"topics":["android","http3","kotlin","network-client","perfomance","quic"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/VKCOM.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-09-17T14:09:13.000Z","updated_at":"2024-12-19T15:53:07.000Z","dependencies_parsed_at":"2022-08-12T12:01:04.226Z","dependency_job_id":null,"html_url":"https://github.com/VKCOM/KNet","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/VKCOM/KNet","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VKCOM%2FKNet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VKCOM%2FKNet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VKCOM%2FKNet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VKCOM%2FKNet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/VKCOM","download_url":"https://codeload.github.com/VKCOM/KNet/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VKCOM%2FKNet/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":277194709,"owners_count":25777176,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-27T02:00:08.978Z","response_time":73,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","http3","kotlin","network-client","perfomance","quic"],"created_at":"2024-09-25T21:41:46.928Z","updated_at":"2025-09-27T06:32:15.471Z","avatar_url":"https://github.com/VKCOM.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"## KNet\n![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)\n\nAndroid network client based on Cronet. This library let you easily use HTTP/3 and QUIC protocol in your Android projects.\nYou can see more about QUIC here - [mobile](https://www.highload.ru/spb/2021/abstracts/8037) or [product](https://www.highload.ru/spb/2021/abstracts/8035) or [backend](https://www.highload.ru/spb/2021/abstracts/8034)\n\n### Order:\n- [Wrapper improovements](#impr)\n- [Gradle](#gradle)\n- [Initialization](#init)\n- [OkHttp Integration](#okhttp)\n- [Comming Soon](#soon)\n- [Licence](#lic)\n\n## \u003ca name=\"impr\"\u003e\u003c/a\u003e Cronet wrapper improvements:\n- Memory Optimizations\n- Multithreading Optimizations\n- Redirects Settings\n- Quic Configurations\n- Timeouts Settings\n- Broken Hosts Clearing\n- Documentation\n- Interceptor System\n- Debug System\n- Metrics\n- Error Handling\n- **(soon)** Fallback System\n- **(soon)** Encodings\n- **(soon)** Tests\n- **(soon)** Integrations(ExoPlayer/Ktor/Okhttp/Flipper/Stetho)\n- **(soon)** Backoff\n- **(soon)** DNS Prefetch\n\n## \u003ca name=\"gradle\"\u003e\u003c/a\u003e Gradle\nYou can try this library using Gradle:\n``` groovy\ndependencies {\n implementation 'com.vk.knet:core:1.0'\n implementation 'com.vk.knet:cronet:1.0'\n implementation 'com.vk.knet:okcronet:1.0'\n}\n```\n\n## \u003ca name=\"init\"\u003e\u003c/a\u003e Initialization\nShort version:\n```kotlin\nval cronet = CronetKnetEngine.Build(App.context) {\n    client {\n        enableQuic(\n            CronetQuic(hints = listOf(Host(\"drive.google.com\", 443)))\n        )\n    }\n}\n\nval knetCronet = Knet.Build(cronet)\n```\n\nFull version:\n```kotlin\nCronetLogger.global(\n    object : CronetHttpLogger {\n        override fun error(vararg obj: Any) {\n            Log.e(\"Logos\", obj.toList().toString())\n        }\n\n        override fun debug(type: CronetHttpLogger.DebugType, vararg obj: Any) {\n            Log.d(\"[${type.name}]\", obj.toList().toString())\n        }\n\n        override fun info(vararg obj: Any) {\n            Log.i(\"Logos\", obj.toList().toString())\n        }\n    }\n)\n\nprivate val cronet = CronetKnetEngine.Build(App.context) {\n    client {\n        setCache(CronetCache.Disk(App.context.filesDir, 1024 * 1024 * 10))\n\n        enableHttp2(true)\n        enableQuic(\n            CronetQuic(\n                hints = listOf(\n                    Host(\"drive.google.com\", 443)\n                ),\n            )\n        )\n\n        useBrotli(true)\n        isClearBrokenHosts(true)\n\n        netlog(CronetLog.Config(netDir, 1024 * 1024 * 100))\n\n        connectTimeout(15, TimeUnit.SECONDS)\n        writeTimeout(15, TimeUnit.SECONDS)\n        readTimeout(15, TimeUnit.SECONDS)\n\n        nativePool(CronetNativeByteBufferPool.DEFAULT)\n        arrayPool(ByteArrayPool.DEFAULT)\n\n        maxConcurrentRequests(50)\n        maxConcurrentRequestsPerHost(10)\n\n        followRedirects(true)\n        followSslRedirects(true)\n\n        addMetricListener { metric: HttpMetrics, _, _ -\u003e\n            Metrics.addMetric(metric)\n        }\n    }\n\n    addInterceptor { p -\u003e\n        try {\n            p.proceed(p.request)\n        } catch (e: Exception) {\n            try {\n                println(\"[KNet] [RETRY ${if (e is ConnectException) e.message else e.localizedMessage}]\")\n                p.proceed(p.request)\n            } catch (e: Exception) {\n                e.printStackTrace()\n                throw e\n            }\n        }\n    }\n}\n\nval knetCronet = Knet.Build(cronet) {\n    bufferPool(ByteArrayPool.DEFAULT)\n}\n```\n\n## \u003ca name=\"okhttp\"\u003e\u003c/a\u003e OkHTTP\nIf you're now using OkHttp, you can simply wrap KNet into OkHttp Interceptor... Easy, right?\n\n```kotlin\nval knetCronet = Knet.Build(cronet)\nval okhttpInterceptor = KnetToOkHttpInterceptor(knetCronet)\n\nval builder = OkHttpClient.Builder()\nbuilder.addInterceptor(okhttpInterceptor)\nval client = builder.build()\n```\n\n\n## \u003ca name=\"soon\"\u003e\u003c/a\u003e Comming Soon\n- Tests\n- Exo\n- Ktor\n- OkHttp\n- Flipper\n- Stetho\n\n## \u003ca name=\"lic\"\u003e\u003c/a\u003e Licence\n```\nThe MIT License (MIT)\n\nCopyright (c) 2019 vk.com\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvkcom%2Fknet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvkcom%2Fknet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvkcom%2Fknet/lists"}