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.

[Suggestion] Automatic reconnect

See original GitHub issue

Could you please add function to the Android app or to the desktop one, so gnirehtet will be reconnected after was disconnected due to USB cable unplug (Once USB is plugged again I mean). So you don’t need to restart desktop app in order to reconnect your device (I currently haven’t found yet command to reconnect it from the device).

Thank you for great app!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:14

github_iconTop GitHub Comments

2reactions
autolainencommented, Feb 1, 2018

Want to share how I solved problem with client reconnection after usb cable unplugged and then plugged back in:

       ...
       ,RELAY_RECONNECT("relay-reconnect", CommandLineArguments.PARAM_NONE) {
            @Override
            String getDescription() {
                return "Start the relay server in reconnect mode.";
            }

            @Override
            void execute(CommandLineArguments args) throws Exception {

                new Thread(() -> {
                    while (true) {
                        try {
                            Socket s = new Socket("127.0.0.1", 5037);
                            s.getOutputStream().write("0012host:track-devices".getBytes(Charset.forName("ASCII")));

                            byte buf[] = new byte[5 * 1024];
                            int r;
                            while ((r = s.getInputStream().read(buf)) >= 0) {
                                if (r > 0) {
                                    try {
                                        execAdb(args.getSerial(), "reverse", "tcp:31416", "tcp:31416");
                                    } catch (Exception ex) {
                                        Log.e(TAG, "Cannot start client", ex);
                                    }
                                }
                            }
                        } catch (Exception e) {
                            try {
                                wait(30 * 1000);
                            } catch (Exception e1) {
                                // ignore
                            }
                        }
                    }
                }).start();

                relay();
            }

I added this is piece of code to Main.class so now I can start the server with command ‘java -jar ginerhtet-server.jar relay-reconnect’ and connect my mobile device by usb many times and it gets internet connection automatically. Hope it’ll make your life easier!

1reaction
rom1vcommented, Feb 3, 2018

@autolainen Thanks to your work, I implemented the feature on the Java version (I will also implement it in rust).

I added two commands:

  • gnirehtet autostart executes gnirehtet start on every new connected device;
  • gnirehtet autorun executes gnirehtet autostart in background and gnirehtet relayin foreground.

The branch is wip/autostart. Feedbacks welcome.

I’ll merge it in dev once the Rust version is implemented.

Read more comments on GitHub >

github_iconTop Results From Across the Web

I can suggest a auto reconnect feature - Colonist.io
I can suggest a auto reconnect feature - Colonist.io.
Read more >
[Update: Not quite] Android Q won't automatically reconnect to ...
During the blacklist period, that network will not be considered for auto-connection, even if the app removes and re-adds the network suggestion ......
Read more >
How to avoid automatic reconnect to data sources at startup?
My question is about the following scenario. I close Data Studio (4.1.1 / Linux) with some SQL Script files open that are connected...
Read more >
Suggestion: Auto reconnect of WebCam when lost - Yawcam
Suggestion : Auto reconnect of WebCam when lost ... Been using yaw cam for the last week with no issues but found this...
Read more >
How to get computer to reconnect automatically after ...
I would suggest you to try the steps mentioned below. Step 1: Use the network troubleshooter in Windows 7. http://windows.microsoft.com/en-US/ ...
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