以下在代理后面的lan中提供错误,但在局域网/代理之外正常工作。 请让我知道如何纠正它
我使用代码检测代理设置,它给出了
Detecting Windows/IE proxy setting using Java
我得到:代理主机名:DIRECT没有代理这是否意味着我不在代理服务器后面?
我正在尝试使用java rome-fetcher获取rss feed以进行处理。当我有直接上网时,一切正常。
但是,我需要能够在代理服务器后面运行我的应用程序。
以下在局域网中提供错误,但在局域网外正常工作 线程“main”中的异常java.net.ConnectException:连接超时:connect at java.net.PlainSocketImpl.socketConnect(Native Method) 在java.net.PlainSocketImpl.doConnect(未知来源)
import java.util.Properties;
import java.net.*;
import java.io.*;
import java.io.FileWriter;
import java.io.Writer;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Iterator;
import java.util.List;
import com.sun.syndication.feed.synd.SyndEntry;
import com.sun.syndication.feed.synd.SyndFeed;
import com.sun.syndication.io.SyndFeedInput;
import com.sun.syndication.io.SyndFeedOutput;
import com.sun.syndication.io.XmlReader;
public class RomeLibraryExample {
@SuppressWarnings("unchecked")
public static void main(String[] args) throws Exception {
URL url = new URL("http://rss.cnn.com/rss/cnn_topstories.rss");
//System.setProperty("http.proxyHost", "DIRECT");
// System.setProperty("http.proxyPort", "8080");
HttpURLConnection httpcon = (HttpURLConnection)url.openConnection(Proxy.NO_PROXY);
// Reading the feed
SyndFeedInput input = new SyndFeedInput();
SyndFeed feed = input.build(new XmlReader(httpcon));
List<SyndEntry> entries = feed.getEntries();
Iterator<SyndEntry> itEntries = entries.iterator();
while (itEntries.hasNext()) {
SyndEntry entry = itEntries.next();
System.out.println("Title: " + entry.getTitle());
System.out.println("Link: " + entry.getLink());
System.out.println("Author: " + entry.getAuthor());
System.out.println("Publish Date: " + entry.getPublishedDate());
System.out.println("Description: " + entry.getDescription().getValue());
System.out.println();
}
}
}