我正在尝试使用 Silvertunnel Netlib ( https://silvertunnel.org/doc/netlib.html )从 Tor 网络上的 Java 应用程序中发出匿名 HTTP 请求。我正在使用示例代码,该代码在通过 TCPIP 发出请求时有效,但在使用 TOR 设置时,它以以下异常结束(尝试连接大约 10 分钟后):
java.io.IOException: Tor.connect: unable to connect to null:80 after 11 full retries with 5 sub retries
at org.silvertunnel.netlib.layer.tor.clientimpl.Tor.connect(Tor.java:281)
at org.silvertunnel.netlib.layer.tor.TorNetLayer.createNetSocket(TorNetLayer.java:113)
at org.silvertunnel.netlib.util.HttpUtil.get(HttpUtil.java:121)
at FlightBot.main(FlightBot.java:48)
这是我正在使用的代码:
NetLayer lowerNetLayer = NetFactory.getInstance().getNetLayerById(NetLayerIDs.TOR);
// wait until TOR is ready (optional) - this is only relevant for anonymous communication:
lowerNetLayer.waitUntilReady();
// prepare parameters (http default port: 80)
TcpipNetAddress httpServerNetAddress = new TcpipNetAddress("httptest.silvertunnel.org", 80);
String pathOnHttpServer = "/httptest/bigtest.jsp?id=example";
long timeoutInMs = 5000;
// do the HTTP request and wait for the response
byte[] responseBody = HttpUtil.getInstance().get(lowerNetLayer, httpServerNetAddress, pathOnHttpServer, timeoutInMs);
// print out the response
System.out.println(new String(responseBody));
是我做错了什么还是 Tor 网络目前不可用?
需要明确的是,它在使用时有效:
NetLayer lowerNetLayer = NetFactory.getInstance().getNetLayerById(NetLayerIDs.TCPIP)
在第一行。