我正在查看silvertunnel库,但正在努力建立一个成功的连接。我遇到的问题是,连接需要超过10分钟才能输出。我正在查看他们的一个tests,这是我的代码:
public boolean tryConnOLD() throws IOException {
try {
// define remote address
String remoteHostname = "http://test.silvertunnel.com";
int remotePort = 80;
TcpipNetAddress remoteAddress = new TcpipNetAddress(remoteHostname, remotePort);
// get TorNetLayer instance and wait until it is ready
NetLayer netLayer = NetFactory.getInstance().getNetLayerById(NetLayerIDs.TOR);
netLayer.waitUntilReady();
// open connection to remote address - this connection is tunneled through the TOR anonymity network
netSocket = netLayer.createNetSocket(null, null, remoteAddress);
InputStream is = netSocket.getInputStream();
String content = CharStreams.toString(new InputStreamReader(is, Charsets.UTF_8));
Closeables.closeQuietly(is);
is.close();
System.out.println(is.read());
java.util.Scanner s = new java.util.Scanner(is).useDelimiter("\\A");
if(s.hasNext()) {
System.out.println(s.next());
System.out.println();
}
return true;
} catch (IOException ex) {
} finally {
netSocket.close();
}
return false;
}发布于 2013-02-12 21:15:28
问题很简单,当你使用silvertunnel API时,你不需要在url中指定协议,所以只需删除http://就可以修复你的错误。
请尝试以下操作
//remove http://
String remoteHostname = "test.silvertunnel.com";https://stackoverflow.com/questions/14814749
复制相似问题