Reputation: 2298
I am trying to use RN's fetch()
method with http connection alive.
I tried with header 'Connection: keep-alive' but it does not seem to work. I cannot use http.Agent
because http
module is not supported in React Native. I searched but cannot find an alternative module.(XmlHttpRequest does not work also)
Question: What can I do to keep http connection alive in React Native's environment?
My ultimate purpose is to authenticate a NTLM server in React Native's JavaScriptCore, the authentication needs keep-alive http connection. Any other suggestion is also appreciated.
Upvotes: 9
Views: 3433
Reputation: 13458
On Android (and presumably similarly on iOS), the OkHttp client used by ReactNative will by default keep either a Http/1.1 or Http/2 connection alive and reuse it. You should check whether the server is closing the response.
https://en.wikipedia.org/wiki/HTTP_persistent_connection#HTTP_1.1
Upvotes: 2
Reputation: 595
We created the native module in android/ios to open network connection in JAVA and Objective C and emit events on response.
Upvotes: 0