简体   繁体   English

java.net.SocketException:来自服务器的文件意外结束

[英]java.net.SocketException: Unexpected end of file from server

I am using a servlet which passes a String parameter to another Servlet in another remote system, to get xml response from that remote servlet.我正在使用一个 servlet,它将字符串参数传递给另一个远程系统中的另一个 Servlet,以从该远程 servlet 获取 xml 响应。

This works fine when i tried to connect to that remote Servlet from my local PC.当我尝试从本地 PC 连接到该远程 Servlet 时,这工作正常。

But I am getting the error java.net.SocketException: Unexpected end of file from server when I execute same from another server.但是当我从另一台服务器执行相同的操作时,我收到错误java.net.SocketException: Unexpected end of file from server server。

Error:错误:

2011-06-04 11:27:24,305 INFO  [STDOUT] strURL in Inventry --> http://1**.1**.**.27:7777/GatewayServlet
/Status?Str=Inventory&PARTNUM=200A104%27%2C%27200A112%27%2C%27200A114%27%2C%27200A113%27%2C%27200A117%27%2C%27200A120%27%2C%27240A503%27%2C%27200A132%27%2C%27200A128%27%2C%27200A124
2011-06-04 11:28:06,243 ERROR [STDERR] java.net.SocketException: Unexpected end of file from server
2011-06-04 11:28:06,243 ERROR [STDERR]  at sun.net.www.http.HttpClient.parseHTTPHeader(Unknown Source)
2011-06-04 11:28:06,243 ERROR [STDERR]  at sun.net.www.http.HttpClient.parseHTTP(Unknown Source)
2011-06-04 11:28:06,243 ERROR [STDERR]  at sun.net.www.http.HttpClient.parseHTTPHeader(Unknown Source)
2011-06-04 11:28:06,243 ERROR [STDERR]  at sun.net.www.http.HttpClient.parseHTTP(Unknown Source)
2011-06-04 11:28:06,243 ERROR [STDERR]  at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
2011-06-04 11:28:06,243 ERROR [STDERR]  at com.cim.web.servlet.DBGatewayServiceServlet.processRequest(DBGatewayServiceServlet.java:52)
2011-06-04 11:28:06,243 ERROR [STDERR]  at com.cim.web.servlet.DBGatewayServiceServlet.doGet(DBGatewayServiceServlet.java:113)
2011-06-04 11:28:06,243 ERROR [STDERR]  at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
2011-06-04 11:28:06,243 ERROR [STDERR]  at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
2011-06-04 11:28:06,243 ERROR [STDERR]  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
2011-06-04 11:28:06,243 ERROR [STDERR]  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
2011-06-04 11:28:06,243 ERROR [STDERR]  at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
2011-06-04 11:28:06,243 ERROR [STDERR]  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
2011-06-04 11:28:06,243 ERROR [STDERR]  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
2    011-06-04 11:28:06,243 ERROR [STDERR]  at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
2011-06-04 11:28:06,243 ERROR [STDERR]  at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
2011-06-04 11:28:06,243 ERROR [STDERR]  at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
2011-06-04 11:28:06,243 ERROR [STDERR]  at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
2011-06-04 11:28:06,243 ERROR [STDERR]  at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
2011-06-04 11:28:06,243 ERROR [STDERR]  at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
2011-06-04 11:28:06,243 ERROR [STDERR]  at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
2011-06-04 11:28:06,243 ERROR [STDERR]  at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
2011-06-04 11:28:06,243 ERROR [STDERR]  at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
2011-06-04 11:28:06,243 ERROR [STDERR]  at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
2011-06-04 11:28:06,243 ERROR [STDERR]  at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
2011-06-04 11:28:06,243 ERROR [STDERR]  at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
2011-06-04 11:28:06,243 ERROR [STDERR]  at java.lang.Thread.run(Unknown Source)

Code in My Servlet (client): My Servlet(客户端)中的代码:

if(queryString.equals("Inventory")) {

   String partNum = (String)session.getAttribute("PARTNUM");
   String locId = (String)session.getAttribute("locids");

   strURL = strURL+"/InventoryStatus?queryStr=Inventory&PARTNUM="+partNum;

   URLConnection dbGatewayURL = new URL(strURL).openConnection();

   BufferedReader in = new BufferedReader(new InputStreamReader(dbGatewayURL.getInputStream()));//--This is line 52 Mentioned in Error above

   StringBuffer responseData = new StringBuffer();
   String line="";

   while((line = in.readLine()) != null) {
      responseData.append(line);
   }

   String result =responseData.toString();
   request.setAttribute("inventryStock",result);

   RequestDispatcher rd=request.getRequestDispatcher ("inventryStatus.jsp?resp=Yes");
   rd.forward(request, response);  
}

Try to telnet to the remote servlet from your server and see whether it connects as expected.尝试从您的服务器 telnet 到远程 servlet,并查看它是否按预期连接。 If it is not, then that's a connectivity issue.如果不是,那就是连接问题。

If it does, try to use a TCP Monitor to see the HTTP traffic that goes from your server to the remote server which has the servlet.如果是这样,请尝试使用 TCP 监视器查看从您的服务器到具有 servlet 的远程服务器的 HTTP 流量。 http://ws.apache.org/commons/tcpmon/ http://ws.apache.org/commons/tcpmon/

try to wait() immediately after URLConnection dbGatewayURL = new URL(strURL).openConnection();尝试在 URLConnection dbGatewayURL = new URL(strURL).openConnection() 之后立即等待();

It is possible the program moved to the next line before it was able to make the connection程序可能在能够建立连接之前移动到下一行

There was nothing wrong with the code but the thing was the remote server wasn't listening to the connection from my server, hence i tried the same code but on another remote server this time and its working fine..... any body know the reason...........??代码没有任何问题,但问题是远程服务器没有监听来自我的服务器的连接,因此我尝试了相同的代码,但这次在另一台远程服务器上运行良好......任何人都知道原因...........??

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 引起:java.net.SocketException:来自服务器的文件意外结束 - Caused by: java.net.SocketException: Unexpected end of file from server 异常:java.net.SocketException:来自服务器的文件意外结束 - Exception: java.net.SocketException: Unexpected end of file from server Java简单代码:java.net.SocketException:来自服务器的文件意外结束 - Java simple code: java.net.SocketException: Unexpected end of file from server Solr SimplePostTool:读取响应时出现IOException:java.net.SocketException:服务器中的文件意外结束 - Solr SimplePostTool: IOException while reading response: java.net.SocketException: Unexpected end of file from server java.net.SocketException:服务器中的文件意外结束[但是此消息仅与一个特定的用户登录一起出现 - java.net.SocketException:Unexpected end of file from the server [but this message comes only with one particular user login javax.ws.rs.ProcessingException:java.net.SocketException:服务器中的文件意外结束 - javax.ws.rs.ProcessingException : java.net.SocketException: Unexpected end of file from server URLConnection无法发送完整的URL(java.net.SocketException:服务器上的文件意外结束) - URLConnection does not send full URL (java.net.SocketException: Unexpected end of file from server) HttpUrlConnection getOutputStream()抛出java.net.SocketException:服务器上的文件意外结束 - HttpUrlConnection getOutputStream() throwing java.net.SocketException: Unexpected end of file from server (SAXON DTD)java.net.SocketException:来自服务器的文件意外结束 - (saxon dtd)java.net.SocketException: Unexpected end of file fromserver java.net.SocketException:来自 SOCKS 服务器的错误回复 - java.net.SocketException: Malformed reply from SOCKS server
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM