Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- added: Websocket Module setCustomClientBuilder (facebook#37798)
Summary: Added code previously added in the following PR: facebook#28659. The above PR was accidentally scrapped due to the renaming of the master branch on the React Native repo. As advised in this comment: facebook#37770 (comment), I'm opening a new PR with the same code to get this merged into master / main. Currently, we need to run a local fork of React Native and manually apply these changes ourselves. This then causes additional issues, as it's currently _**impossible**_ to build React Native from source when running on a Windows machine, as evidenced in facebook#37770 and the other linked issues nested inside of this issue. **Original summary is as follows:** With `NetworkModule.setCustomClientBuilder` we can customize our OkHttpClient to all requests made by react-native, it's very useful when you do `SSL Pinning` or change some OkHttpClient configuration at all. I've added a similar function to websocket, it allow us do some configurations on Websocket OkHttpClient. [Android] [Added] - Websocket Module setCustomClientBuilder <!-- Help reviewers and the release process by writing your own changelog entry. Pick one each for the category and type tags: [ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message For more details, see: https://reactnative.dev/contributing/changelogs-in-pull-requests Pull Request resolved: facebook#37798 Test Plan: **From the original PR:** You can just set a custom `CustomClientBuilder` on `MainActivity` `onCreate`: ``` import okhttp3.OkHttpClient; import java.util.concurrent.TimeUnit; import com.facebook.react.modules.network.CustomClientBuilder; import com.facebook.react.modules.websocket.WebsocketModule; public class MainActivity extends ReactFragmentActivity { Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); RNBootSplash.init(R.drawable.launch_screen, MainActivity.this); WebsocketModule.setCustomClientBuilder(new CustomClientBuilder() { Override public void apply(OkHttpClient.Builder builder) { builder.connectTimeout(0, TimeUnit.MILLISECONDS); } }); } ... ``` Reviewed By: cortinico Differential Revision: D47468613 Pulled By: javache fbshipit-source-id: ad97fb18ba5784d8abe157f5ccd29201b8b0fe84
- Loading branch information