在unix box上部署java代码时无法打开URL连接
下面的代码打开一个连接: 当我在Windows上本地运行时,这与预期的一样有效,但当我将其部署到unix设备时,会收到401个异常。这向我表明unix框没有发送从本地计算机运行时发送的某些凭据。我不认为这是代理问题,因为我在运行上述代码之前设置代理凭据 我的分析正确吗?这是一个凭据问题?如果是这样,我如何发现本地运行的额外详细信息正在发送?jvm是否在文件夹/文件中查找这些凭据,而unix设备上不存在这些凭据在unix box上部署java代码时无法打开URL连接,java,unix,Java,Unix,下面的代码打开一个连接: 当我在Windows上本地运行时,这与预期的一样有效,但当我将其部署到unix设备时,会收到401个异常。这向我表明unix框没有发送从本地计算机运行时发送的某些凭据。我不认为这是代理问题,因为我在运行上述代码之前设置代理凭据 我的分析正确吗?这是一个凭据问题?如果是这样,我如何发现本地运行的额外详细信息正在发送?jvm是否在文件夹/文件中查找这些凭据,而unix设备上不存在这些凭据 或者,我是否需要在使用Wireshare或类似工具运行程序时检查发送的通信量?发布错误
或者,我是否需要在使用Wireshare或类似工具运行程序时检查发送的通信量?发布错误。然后尝试
curlhttp://www.google.com
在那个框上。@talex yes curl返回相同的错误,谢谢
try {
long startTime = System.currentTimeMillis();
URL url = new URL("http://www.google.com");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.connect();
BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
StringBuilder out = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
out.append(line);
}
long endTime = System.currentTimeMillis();
LOGGER.info(urlName +" response time : " + (endTime - startTime) + " milliseconds");
if ((endTime - startTime) > 30000) {
LOGGER.info("********************************** Possible server lag *****************************************");
}
} catch (MalformedURLException mue) {
System.out.println("MalformedURLException");
System.out.println(mue.getMessage());
mue.printStackTrace();
} catch (IOException ioe) {
System.out.println("IOException");
System.out.println(ioe.getMessage());
ioe.printStackTrace();
System.out.println("url is "+urlName);
System.out.println("Now exiting");
}