socket.io-client icon indicating copy to clipboard operation
socket.io-client copied to clipboard

React Native 47 gets xhr poll error with https server that has self signed certificate

Open HessiPard opened this issue 7 years ago • 4 comments

You want to:

  • [x] report a bug
  • [ ] request a feature

Current behaviour

with react-native 0.47 in client and https node server with self signed certificate, i get xhr poll error even with rejectUnauthorized: false ... while i test it on node client with rejectUnauthorized: false and it works. is it a problem with android?

Setup

  • socket.io version: 2.0.3

HessiPard avatar Sep 19 '17 07:09 HessiPard

having same issue as above. ios is working fine with cert encrypted via lets encrypt. however does not work on android.

jimji1005 avatar Oct 20 '17 18:10 jimji1005

Same issue here

Schachte avatar May 19 '18 06:05 Schachte

same issue

qdieppe avatar Jul 24 '18 00:07 qdieppe

try last version from github, like this, solved my issues with RN android:

npm i socketio/engine.io-client#3.3.2 -S

diegolaciar avatar Jul 15 '19 21:07 diegolaciar

For future readers:

This can be achieved with the following configuration:

android/app/src/debug/AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest>

    <application
        android:networkSecurityConfig="@xml/network_security_config"
    />
</manifest>

android/app/src/debug/res/xml/network_security_config.xml

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <!-- needed by the Metro dev server -->
    <domain-config cleartextTrafficPermitted="true">
        <domain>localhost</domain>
    </domain-config>

    <domain-config>
        <domain>192.168.0.10</domain>
        <trust-anchors>
            <certificates src="@raw/mycert" />
        </trust-anchors>
    </domain-config>
</network-security-config>

android/app/src/debug/res/raw/mycert.pem

-----BEGIN CERTIFICATE-----
[...]
-----END CERTIFICATE-----

Added in the documentation here: https://socket.io/how-to/use-with-react-native

darrachequesne avatar Apr 10 '24 10:04 darrachequesne