2013-01-17 74 views
2

我有一個Java應用程序向Jetty服務器發出REST請求。到本地主機的HTTP連接失敗

它的工作原理,如果我連接到一個真正的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:0:1]/

它總是以本地主機爲我工作。有些Java或Windows 7更新可能會更改默認設置,因此它使用IPv6而不是?

我可以做些什麼來使localhost再次工作,我需要擔心這可能會導致其他PC上的問題,當他們想要連接到我們的真實服務器?

我想與IPv4和IPv6兼容。

編輯:這裏是我的hosts文件(這是未經編輯)

# 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 
+0

'StreamClosed'不是由連接失敗造成的。另一端的東西關閉了已經打開的連接。 –

+0

請看 http://stackoverflow.com/questions/7023523/bind-jetty-to-ipv6-address – iMysak

回答

相關問題