9

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.

Wint
  • 2,268
  • 2
  • 22
  • 32

2 Answers2

2

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

Yuri Schimke
  • 12,435
  • 3
  • 35
  • 69
0

We created the native module in android/ios to open network connection in JAVA and Objective C and emit events on response.

Anurag Chutani
  • 591
  • 1
  • 4
  • 15