Java 到本地主机的HTTP连接失败

Java 到本地主机的HTTP连接失败,java,rest,jersey,jetty,ipv6,Java,Rest,Jersey,Jetty,Ipv6,我有一个Java应用程序,它向Jetty服务器发出REST请求 如果我使用真实的DNS名称连接到服务器,它会起作用,但当我想向本地主机上的本地测试实例发出请求时,会出现以下异常: Caused by: com.sun.jersey.api.client.ClientHandlerException: java.io.IOException: Stream closed at com.sun.jersey.api.client.ClientResponse.hasEntity(Client

我有一个Java应用程序,它向Jetty服务器发出REST请求

如果我使用真实的DNS名称连接到服务器,它会起作用,但当我想向本地主机上的本地测试实例发出请求时,会出现以下异常:

Caused by: com.sun.jersey.api.client.ClientHandlerException: java.io.IOException: Stream closed
    at com.sun.jersey.api.client.ClientResponse.hasEntity(ClientResponse.java:480) ~[jersey-client-1.14.jar:1.14]
    at com.sun.jersey.client.apache.ApacheHttpClientHandler.handle(ApacheHttpClientHandler.java:182) ~[jersey-apache-client-1.14.jar:1.14]
    ... 12 common frames omitted
Caused by: java.io.IOException: Stream closed
    at java.io.BufferedInputStream.getBufIfOpen(BufferedInputStream.java:162) ~[na:1.7.0_05]
    at java.io.BufferedInputStream.reset(BufferedInputStream.java:435) ~[na:1.7.0_05]
    at java.io.FilterInputStream.reset(FilterInputStream.java:226) ~[na:1.7.0_05]
    at java.io.FilterInputStream.reset(FilterInputStream.java:226) ~[na:1.7.0_05]
    at com.sun.jersey.api.client.ClientResponse.hasEntity(ClientResponse.java:464) ~[jersey-client-1.14.jar:1.14]
    ... 13 common frames omitted
浏览器中的请求和使用我的REST工具工作

当我使用本地主机的IPv6地址时,它开始工作:
https://[0:0:0:0:0:0:1]/

对于我来说,localhost总是很管用。是否有可能某些Java或Windows 7更新更改了默认设置,从而改用IPv6

我该怎么做才能使localhost再次工作?我是否需要担心,当其他PC想要连接到我们真正的服务器时,这可能会导致其他PC出现问题

我希望IPv4和IPv6兼容

编辑:这是我的主机文件(未编辑)


所以我终于找到了问题所在。显然Skype使用端口80和443作为替代端口。 我一退出Skype,一切都正常了


它可能与IPv6本地主机地址一起工作,因为Skype没有绑定到该地址。

StreamClosed
不是由于连接失败造成的。另一端有东西关闭了已经打开的连接。请注意
# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host

# localhost name resolution is handled within DNS itself.
#   127.0.0.1       localhost
#   ::1             localhost