1. 程式人生 > >weblogic中 java.net.SocketException: Connection reset

weblogic中 java.net.SocketException: Connection reset

關於:java.net.SocketException: Connection reset
關鍵資訊:一個請求中包含了兩個POST資料包
以前經常聽說關於這個錯誤,沒有太多在意,認為我寫的框架應該沒有問題,第一感覺是網路不穩定產生的。
今天在一次偶爾的測試中,發現這個問題頻繁的出現:
java.net.SocketException: Connection reset
 at java.net.SocketInputStream.read(SocketInputStream.java:168)
 at weblogic.servlet.internal.PostInputStream.read(PostInputStream.java:170)
 。。。 。。。
--------------- nested within: ------------------
weblogic.utils.NestedRuntimeException: Cannot parse POST parameters of request: '/beacon/txn993101.do' - with nested exception:
[java.net.SocketException: Connection reset]
 at weblogic.servlet.internal.ServletRequestImpl.mergePostParams(ServletRequestImpl.java:1277)
 。。。 。。。 起初懷疑是服務端的問題,經過一番努力,確認doPost已經正常結束,並且在我控制不了的地方,立刻又發起了另一個doPost,第二個doPost的處理中,Weblogic認為連線已經關閉,所以才出了上面的錯誤
根據這個現象,懷疑是IE在提交的資料裡面,包含了兩個POST請求,好象不可思議,至少我認為不會產生這種低階錯誤。
進一步的測試發現,通過 <BUTTON onclick="forms[X].submit"> 的請求是正常的,而 <INPUT onkeydown="forms[X].submit"> 的請求,肯定會有上面的錯誤,當然具體的程式碼要複雜的多。
在代理伺服器上看到的資訊,後一個請求確實包含了兩個POST資料包,如下:
POST /beacon/txn993101.do HTTP/1.0
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*
Referer:
http://169.1.1.185:7001/beacon/freeze.main?txn-code=show&path=/module/console/error-report&page=/txn993101.do&cmd=′
??′′|mμ?
Accept-Language: zh-cn
Content-Type: application/x-www-form-urlencoded
UA-CPU: x86
Pragma: no-cache
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; .NET CLR 1.1.4322; InfoPath.1)
Host: 169.1.1.185:7001
Content-Length: 480
Proxy-Connection: Keep-Alive
Cookie: JSESSIONID=EbNUakFYENcyMF6x3s10OsgWyrFuk9yCMGnhr2U4hgZkBInx00nW!860387529 Close Http Link[169.1.1.185:7001][http://169.1.1.185:7001/beacon/txn993101.do]
POST /beacon/txn993101.do HTTP/1.0
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*
Referer:
http://169.1.1.185:7001/beacon/freeze.main?txn-code=show&path=/module/console/error-report&page=/txn993101.do&cmd=′
??′′|mμ?
Accept-Language: zh-cn
Content-Type: application/x-www-form-urlencoded
UA-CPU: x86
Pragma: no-cache
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; .NET CLR 1.1.4322; InfoPath.1)
Host: 169.1.1.185:7001
Content-Length: 480
Proxy-Connection: Keep-Alive
Cookie: JSESSIONID=EbNUakFYENcyMF6x3s10OsgWyrFuk9yCMGnhr2U4hgZkBInx00nW!860387529
inner-flag%3Aflowno=11552227467156&inner-flag%3Aopen-type=window&inner-flag%3Amodify-flag=true&inner-flag%3Areload-flag=yes&inner-flag%3Acontinue-flag=yes&inner-flag%3Anext-page=&inner-flag%3Asuccess-hint=&inner-flag%3Afailure-hint=&inner-flag%3Aload-node=&inner-flag%3Amenu-name=&inner-flag%3Asuccess-number=1&attribute-node%3Arecord_selected-key=&attribute-node%3Arecord_record-number=11&record_selectPage=1&attribute-node%3Arecord_page-row=5&attribute-node%3Arecord_start-row=1
而前一個請求只包含一個POST資料包,問題得到了確認,那應該是javascript的程式碼有問題,修改是很簡單的,INPUT的event中return false就可以了,例如:
<INPUT onkeydown="forms[X].submit;return false;">