我有2個包 - 1 Server在傳統的Web服務器維護(Tomcat的6,7的Websphere)和1對即時網絡服務器碼頭,它作爲一個客戶。 服務器和代理Windows 7機器上完全本地工作和JRE 6: (1)服務器被加載到Tomcat。 (2)代理使用自定義端口初始化Jetty 8 Web服務器。WebSphere服務器和Jetty客戶端java.lang.illegalstateexception狀態==頭
當我把它在生產 - Linux環境 - 我裝了戰爭的WebSphere,這似乎很好地工作。我在生產中使用'jave -jar'執行代理jar,它似乎工作。他們溝通後 - 如果在'java.lang.illegalstateexception:state == header'異常失敗,則與代理失敗。
現在,我引用的WebSphere產品應用到我的本地計算機,所有的通訊(本地代理與Windows 7,服務器遠程在Linux上)工作正常。
因此,它似乎有一個與代理問題(或者其內部碼頭),代碼是這樣的:
private void respondOK(Request baseRequest, HttpServletResponse response)
throws IOException {
response.setContentType("text/html;charset=utf-8");
response.setStatus(HttpServletResponse.SC_OK);
baseRequest.setHandled(true);
response.getWriter().println("OK");
}
private boolean handleAgentMonitoringTasks(
Request baseRequest,
HttpServletRequest request,
HttpServletResponse response) {
boolean didRespond = false;
// extract the agent data
try {
String reqContent = readRequestContent(baseRequest);
// handle the input
theAgentWorker.updateTasksList(reqContent);
} catch (IOException e) {
// send a response indicating the error
respondError(baseRequest, response, "Error getting request content - " + e.getMessage(), e);
didRespond = true;
}
return didRespond;
}
private boolean handleServerInfo( Request baseRequest,
HttpServletRequest request,
HttpServletResponse response) {
boolean didRespond = false;
// extract the request content
try {
String reqContent = readRequestContent(baseRequest);
if (reqContent.length() > 0) {
try {
theAgentWorker.handleServerInfoData(reqContent);
}
catch (Exception e) {
respondError(baseRequest, response, "Error setting server information - " + e.getMessage(), e);
didRespond = true;
}
}
else {
respondError(baseRequest, response, "Server address not found in the request", null);
didRespond = true;
}
} catch (IOException e) {
// send a response indicating the error
respondError(baseRequest, response, "Error getting request content - " + e.getMessage(), e);
didRespond = true;
}
return didRespond;
}
private String readRequestContent(Request baseRequest) throws IOException {
BufferedReader br = baseRequest.getReader();
StringBuilder sBuilder = new StringBuilder();
char[] buff = new char[4092];
int charsRead = br.read(buff, 0, buff.length);
while (charsRead == buff.length) {
sBuilder.append(buff);
charsRead = br.read(buff, 0, buff.length);
}
sBuilder.append(buff,0, charsRead);
return sBuilder.toString();
}
所有上面的代碼進入這個類: 公共類AgentHttpHandler擴展AbstractHandler
AbstractHandler是Jetty的處理程序類。
當我研究它時,發現Jetty中存在getReader()和getInputStream()方面的問題,但我無法找到合理的解釋,爲什麼它很不合理 - 在Windows 7中代理工作正常,在Linux上它有問題(我嘗試了幾個Linux服務器)。
你知不知道有碼頭WebServer的某些Linux的網絡問題? 我有更多的信息,但我認爲,這個信息應該是足夠