tor-android icon indicating copy to clipboard operation
tor-android copied to clipboard

NullPointerException when accessing TorControlConnection too early

Open grote opened this issue 2 years ago • 2 comments

When a user of TorService starts and binds to the service, then (as documented) tries to use the TorControlConnection, it can happen that it hasn't been assigned and a NullPointerException is thrown. This is because the TorControlConnection gets only assigned in another thread after doing some extra work.

How is a user of the library supposed to know when the control connection becomes available? Are they expected to register a broadcast receiver and wait for the TorService.STATUS_ON event? That would be quite a cumbersome, but possible solution. If it is that, it should at least get documented.

grote avatar Nov 25 '21 17:11 grote

By chance, I just stumbled about this unconventional workaround in Orbot.

grote avatar Nov 25 '21 21:11 grote