Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native Android Unable to connect to WebSocket

Although the Web implementation works, the android emulator as well as my device does not connect to WebSocket. The following event error code is received where the error is thrown and then disconnected:

    connection error 
Event {
  "isTrusted": false,
  "message": "Failed to connect to /127.0.0.1:8000",
}
connection closed
Event {
  "isTrusted": false,
  "message": "Failed to connect to /127.0.0.1:8000",
}
like image 904
sib Avatar asked Nov 14 '25 11:11

sib


1 Answers

The default websocket port for android emulator is the following, which is different from web.

  android: "http://10.0.2.2:8000",
  web: "http://127.0.0.1:8000",
like image 106
sib Avatar answered Nov 17 '25 10:11

sib



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!