birdofpreyru / react-native-static-server

Embedded HTTP server for React Native
https://dr.pogodin.studio/docs/react-native-static-server
Other
142 stars 22 forks source link

[Android]: Native implementation of `getOpenPort()` potentially needs a patch #36

Closed birdofpreyru closed 1 year ago

birdofpreyru commented 1 year ago

https://github.com/birdofpreyru/react-native-static-server/blob/458348a3e3345542a6092b83654dc1f7a9094248/android/src/main/java/com/drpogodin/reactnativestaticserver/ReactNativeStaticServerModule.java#L140

To try instead:

ServerSocket socket = new ServerSocket();
socket.setReuseAddress(true);
socket.bind(null);

Otherwise, it seems, occasionally server may fail to bind to an automatically selected port as it stays in TIME_WAIT state after the selection.

birdofpreyru commented 1 year ago

Not really needed.