Unable to connect on React-Native (only in Debug Mode)
See original GitHub issueYou want to:
- report a bug
- request a feature
Current behaviour
I can’t connect via socket io to my server, it times out.
Steps to reproduce (if the current behaviour is a bug)
In react-native:
import io from 'socket.io-client';
const BACKEND = 'my socketio server url'
const sock = io(BACKEND, { transports: ['websocket'], forceNew: true });
sock.on('connected', () = {
debugger;
})
The debug logs look like:
There is nothing only a timeout triggered
Expected behaviour
I expect to be able to connect to my socketio server, the same way I am able to in a web browser.
Setup
- OS: Android 8.0
- browser: React-native
- socket.io version: 2.1.1 (but tried differents verisons with same result)
Issue Analytics
- State:
- Created 5 years ago
- Reactions:5
- Comments:19
Top Results From Across the Web
Debugging - React Native
To enable them on macOS, inside the Simulator app, open the I/O menu, select Keyboard, and make sure that "Connect Hardware Keyboard" is ......
Read more >Debugging React Native with react-native-debugger
To use React Native Debugger with your app, you must first run it and enter debug mode. Shake your phone or press Command...
Read more >Debugging - Expo Documentation
You can debug React Native apps using the Chrome debugger tools. Rather than running your app's JavaScript on your phone, it will instead...
Read more >Debugging React Native with VS Code - LogRocket Blog
Debugging React Native with VS Code · Next, you need to create a debug configuration for VS code. · Click the · This...
Read more >Intro to Debugging React Native (iOS and Android) - Medium
For that run: adb reverse tcp:8081 tcp:8081 (see this link for help on adb command). Alternatively, you can open dev menu on the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
FIXED IT for me when i was adding host:port like next in debug mode:
const socket = io(“//domain.com:port”, opts); // this works only in debug mode
didn’t worked in NO debug mode, i had to add the protocol:
const socket = io(“http://domain.com:port”, opts);
Facing the same issue. Works well when debug mode is on, but doesn’t work when Debug mode is turned off or apk is built with release mode.