Java 仅服务器上wikmedia api的连接超时,但在本地

Java 仅服务器上wikmedia api的连接超时,但在本地,java,rest,connection,server,wikipedia,Java,Rest,Connection,Server,Wikipedia,下面的代码在过去三年中一直在工作,但突然之间,它抛出的连接仅在服务器中超时,但在本地主机中工作正常。 有什么评论吗 public String getWikiContent(String query) { StringBuilder builder = new StringBuilder(); String path = "https://en.wikipedia.org/w/api.php?action=query&prop=extracts&exi

下面的代码在过去三年中一直在工作,但突然之间,它抛出的连接仅在服务器中超时,但在本地主机中工作正常。 有什么评论吗

    public  String getWikiContent(String query) {
    StringBuilder builder = new StringBuilder();

    String path = "https://en.wikipedia.org/w/api.php?action=query&prop=extracts&exintro=1&explaintext=1&titles=" + query + "&format=json&redirects";
    try {
        URL url = new URL(path);

        HttpURLConnection urlConn = (HttpURLConnection) url.openConnection();
        urlConn.setRequestProperty("Content-Type",
                "application/json");

        if (urlConn.getResponseCode() != 200) {
            throw new IOException(urlConn.getResponseMessage());
        }

        InputStream is = urlConn.getInputStream();
        BufferedReader buff = new BufferedReader(new InputStreamReader(is));
        String line;

        while ((line = buff.readLine()) != null) {
            builder.append(line);
        }
    }catch (IOException e){
        e.printStackTrace();
    }
    return builder.toString();
   }

由于某些原因,这是一个网络问题,只需添加一个代理服务器即可解决

Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(url,port));
URLConnection urlConn = url.openConnection(proxy);

也许是路由问题?您能否独立于上面的代码,从服务器环境中
curl
URL?
curl
工作正常,输出与前面一样,只有java失败:(