question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to connect on React-Native (only in Debug Mode)

See original GitHub issue

You 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:open
  • Created 5 years ago
  • Reactions:5
  • Comments:19

github_iconTop GitHub Comments

5reactions
ningacodingcommented, Mar 1, 2019

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);

4reactions
mostafiz93commented, Feb 18, 2019

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.

Versions:
"react": "16.8.2",
"react-native": "0.58.4",
"socket.io-client": "^2.2.0"
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found