Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How fix error from TorControlError Error reply: Authentication required #127

Open
zlib-developer opened this issue Sep 29, 2023 · 0 comments

Comments

@zlib-developer
Copy link

zlib-developer commented Sep 29, 2023

I check firebase console section crashlytics and some users get crash because of tor.

stack trace from crashlytics:

java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
    com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1061)
Caused by: java.lang.reflect.InvocationTargetException: 
    java.lang.reflect.Method.invoke(Method.java:0)
    com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:582)
    com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1061)
Caused by: net.freehaven.tor.control.TorControlError: Error reply: Authentication required.
    net.freehaven.tor.control.TorControlConnection.sendAndWaitForResponse(TorControlConnection.java:211)
    net.freehaven.tor.control.TorControlConnection.setEvents(TorControlConnection.java:590)
    com._.zlib.ZlibApp$onCreate$1.onServiceConnected(ZlibApp.kt:101)
    android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java:2293)
    android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:2326)
    android.os.Handler.handleCallback(Handler.java:942)
    android.os.Handler.dispatchMessage(Handler.java:99)
    android.os.Looper.loopOnce(Looper.java:223)
    android.os.Looper.loop(Looper.java:324)
    android.app.ActivityThread.main(ActivityThread.java:8679)
    java.lang.reflect.Method.invoke(Method.java:0)
    com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:582)
    com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1061)

Stacktrace in only one line points to code from my application (ZlibApp.kt:101)

ZlibApp Application class:

//...
    override fun onCreate() {
        super.onCreate()
//...
        bindService(Intent(this, TorService::class.java), object : ServiceConnection {
            override fun onServiceConnected(name: ComponentName?, service: IBinder) {

                val torService: TorService = (service as TorService.LocalBinder).service
                while (torService.torControlConnection == null) {
                    try {
                        Thread.sleep(500)
                    } catch (e: InterruptedException) {
                        e.printStackTrace()
                    }
                }
                Timber.d( "Got Tor control connection, service proxy started")

                //now set our own events
                val events = ArrayList(
                    Arrays.asList(
                        TorControlCommands.EVENT_OR_CONN_STATUS,
                        TorControlCommands.EVENT_CIRCUIT_STATUS,
                        TorControlCommands.EVENT_NOTICE_MSG,
                        TorControlCommands.EVENT_WARN_MSG,
                        TorControlCommands.EVENT_ERR_MSG,
                        TorControlCommands.EVENT_BANDWIDTH_USED,
                        TorControlCommands.EVENT_NEW_DESC,
                        TorControlCommands.EVENT_ADDRMAP
                    )
                )
                if (BuildConfig.DEBUG) {
                    events.add(TorControlCommands.EVENT_DEBUG_MSG)
                    events.add(TorControlCommands.EVENT_INFO_MSG)
                    TorControlCommands.EVENT_STREAM_STATUS
                }

                val conn = torService.torControlConnection
                conn.setEvents(events)                                      // this is 101 line
            }

            override fun onServiceDisconnected(p0: ComponentName?) {
                Timber.d( "Tor service proxy disconnected")
            }

        }, BIND_AUTO_CREATE)

        component = DaggerAppComponent.builder()
            .application(this)
            .build()
    }

I can't reproduce this error on my device or emulator, startup application passes normally on my device.

What could this be?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant