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

Tor issues #23

Open
pasrani opened this issue Apr 4, 2016 · 0 comments
Open

Tor issues #23

pasrani opened this issue Apr 4, 2016 · 0 comments

Comments

@pasrani
Copy link

pasrani commented Apr 4, 2016

Hi,

I am very new to using Tor, so this may be a known problem. I am facing following issues with TorClient, for us the torClient hangs very often, Although this hang doesn't happen very frequently but it does happen repeatedly once in a day,
We have a application which queries whois information for millions of domains, I am copying the code snippet which shows how we use TorClient.

import com.subgraph.orchid.TorClient;
import com.subgraph.orchid.sockets.OrchidSocketFactory;
import org.apache.commons.net.whois.WhoisClient;

import java.io.IOException;

public class WhoisInformationMain {
    private static TorClientHelper torClientHelper;

static {
    try {
        torClientHelper = new TorClientHelper();
    } catch (InterruptedException ie) {
        System.exit(1);
    }
}

public static void main(String... args) {
    WhoisInformationMain whoisinformation = new WhoisInformationMain();
    WhoisClient whoisClient = new WhoisClient();
    whoisClient.setSocketFactory(torClientHelper.getTorSocketFactory());
    whoisClient.setDefaultTimeout(60000);
    String whoisdata = "";
    try {
        whoisClient.connect("com.whois-servers.net");
        whoisdata = whoisClient.query("abc.com");
        whoisClient.disconnect();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

private static class TorClientHelper {

    private final TorClient torClient;
    private final OrchidSocketFactory torSocketFactory;

    public TorClientHelper() throws InterruptedException {
        TorClient torClient = new TorClient();
        torClient.start();
        torClient.waitUntilReady();
        this.torClient = torClient;
        this.torSocketFactory = new OrchidSocketFactory(torClient);
    }


    public TorClient getTorClient() {
        return torClient;
    }

    public OrchidSocketFactory getTorSocketFactory() {
        return torSocketFactory;
    }
}

}
The sample application just shows how we use the TorClient, however in the real system we have 20 threads connecting to server and getting whois information for various domains.
when these threads hang, they show the same stack trace.

java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x000000063b231f98> (a java.lang.Object)
at java.lang.Object.wait(Object.java:503)
at com.subgraph.orchid.circuits.TorInputStream.getNextCell(TorInputStream.java:210)
at com.subgraph.orchid.circuits.TorInputStream.fillBuffer(TorInputStream.java:180)
at com.subgraph.orchid.circuits.TorInputStream.refillBufferIfNeeded(TorInputStream.java:173)
at com.subgraph.orchid.circuits.TorInputStream.read(TorInputStream.java:87)
- locked <0x000000063b231f98> (a java.lang.Object)
- locked <0x000000063b23c180> (a com.subgraph.orchid.circuits.TorInputStream)
at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:283)
at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:325)
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:177)
- locked <0x000000063b231fb0> (a java.io.InputStreamReader)
at java.io.InputStreamReader.read(InputStreamReader.java:184)
at java.io.BufferedReader.fill(BufferedReader.java:154)
at java.io.BufferedReader.read1(BufferedReader.java:205)
at java.io.BufferedReader.read(BufferedReader.java:279)
- locked <0x000000063b231fb0> (a java.io.InputStreamReader)
at org.apache.commons.net.finger.FingerClient.query(FingerClient.java:98)
at org.apache.commons.net.whois.WhoisClient.query(WhoisClient.java:85)

we use 0.13.5 version of bitcoinj-core.

Thanks in advance for pointers, suggestions etc.

Regards
Padma

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