mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Migrate ReconnectingWebSocket to shared OkHttpClient (#55581)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/55581 Replace the inline OkHttpClient.Builder() in ReconnectingWebSocket with DevSupportHttpClient.websocketClient. This shares the connection pool and thread pool with all other devsupport WebSocket consumers. DevSupportHttpClient is changed from internal to public to be accessible from the packagerconnection module, and the packagerconnection BUCK target gains a dependency on the inspector target. Changelog: [Internal] Reviewed By: cipolleschi Differential Revision: D93481092 fbshipit-source-id: b0d6a14e59310e2f975ce92d6bab68f6f6a231da
This commit is contained in:
1 parent
1cef987c1f
commit
0ebe6b6ecc
1 file changed
+2
-8
+2
-8
@@ -10,10 +10,9 @@ package com.facebook.react.packagerconnection
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import com.facebook.common.logging.FLog
|
||||
import com.facebook.react.devsupport.inspector.DevSupportHttpClient
|
||||
import java.io.IOException
|
||||
import java.nio.channels.ClosedChannelException
|
||||
import java.util.concurrent.TimeUnit
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.Request
|
||||
import okhttp3.Response
|
||||
import okhttp3.WebSocket
|
||||
@@ -40,12 +39,7 @@ public class ReconnectingWebSocket(
|
||||
}
|
||||
|
||||
private val handler = Handler(Looper.getMainLooper())
|
||||
private val okHttpClient: OkHttpClient =
|
||||
OkHttpClient.Builder()
|
||||
.connectTimeout(10, TimeUnit.SECONDS)
|
||||
.writeTimeout(10, TimeUnit.SECONDS)
|
||||
.readTimeout(0, TimeUnit.MINUTES) // Disable timeouts for read
|
||||
.build()
|
||||
private val okHttpClient = DevSupportHttpClient.websocketClient
|
||||
private var closed = false
|
||||
private var suppressConnectionErrors = false
|
||||
private var webSocket: WebSocket? = null
|
||||
|
||||
Reference in new issue
Block a user