web-dev-qa-db-ja.com

IOException:Apache 2、mod_jk、およびAJP経由のTomcatを使用したソケットの読み取りに失敗しました

ユーザーがAndroidデバイスからJSON Rest Serviceに接続するときに、次の例外が発生することがあります。

Java.io.IOException: Socket read failed
       at org.Apache.coyote.ajp.AjpProcessor.read(AjpProcessor.Java:313)
       at org.Apache.coyote.ajp.AjpProcessor.readMessage(AjpProcessor.Java:364)
       at org.Apache.coyote.ajp.AjpProcessor.receive(AjpProcessor.Java:331)
       at org.Apache.coyote.ajp.AbstractAjpProcessor.refillReadBuffer(AbstractAjpProcessor.Java:614)
       at org.Apache.coyote.ajp.AbstractAjpProcessor$SocketInputBuffer.doRead(AbstractAjpProcessor.Java:1065)
       at org.Apache.coyote.Request.doRead(Request.Java:422)
       at org.Apache.catalina.connector.InputBuffer.realReadBytes(InputBuffer.Java:290)
       at org.Apache.Tomcat.util.buf.ByteChunk.substract(ByteChunk.Java:431)
       at org.Apache.catalina.connector.InputBuffer.read(InputBuffer.Java:315)
       at org.Apache.catalina.connector.CoyoteInputStream.read(CoyoteInputStream.Java:200)
       at org.codehaus.jackson.impl.ByteSourceBootstrapper.ensureLoaded(ByteSourceBootstrapper.Java:340)
       at org.codehaus.jackson.impl.ByteSourceBootstrapper.detectEncoding(ByteSourceBootstrapper.Java:137)
       at org.codehaus.jackson.impl.ByteSourceBootstrapper.constructParser(ByteSourceBootstrapper.Java:197)
       at org.codehaus.jackson.JsonFactory._createJsonParser(JsonFactory.Java:542)
       at org.codehaus.jackson.JsonFactory.createJsonParser(JsonFactory.Java:389)
       at org.codehaus.jackson.map.ObjectMapper.readValue(ObjectMapper.Java:1454)
       at org.springframework.http.converter.json.MappingJacksonHttpMessageConverter.readInternal(MappingJacksonHttpMessageConverter.Java:124)
       at org.springframework.http.converter.AbstractHttpMessageConverter.read(AbstractHttpMessageConverter.Java:153)
       at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.readWithMessageConverters(HandlerMethodInvoker.Java:641)
       at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolveRequestBody(HandlerMethodInvoker.Java:605)
       at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolveHandlerArguments(HandlerMethodInvoker.Java:354)
       at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.Java:171)
       at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.Java:436)
       at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.Java:424)
       at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.Java:923)
       at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.Java:852)
       at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.Java:882)
       at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.Java:789)

私は走っています

  • Apache/2.2.20
  • mod_jk 1.2.36
  • Tomcat 7.0.27

これはタイムアウトと関係がありますか?クライアントが接続を閉じて、サーバーがソケットから読み取ることができなくなったように?それとも、サーバー構成の問題の可能性が高いですか?

更新:

いくつかのApacheログawkを実行すると、これらのTomcatログ例外に対応する次のApacheログ行が見つかりました。

192.186.30.116 - - [25/Jun/2012:10:47:14 +0200] "POST /myapp/methodX HTTP/1.1" 400 145 "-" "clientApp BlackBerry9360/7.0.0.530 VendorID/168" 10012655 
192.186.30.120 - - [25/Jun/2012:10:53:13 +0200] "POST /myapp/methodY HTTP/1.1" 400 145 "-" "clientApp BlackBerry9800/6.0.0.668 VendorID/124" 10012164 
192.186.30.116 - - [25/Jun/2012:10:53:36 +0200] "POST /myapp/methodZ HTTP/1.1" 400 145 "-" "clientApp BlackBerry9360/7.0.0.530 VendorID/168" 10012677 
192.82.68.16 - - [25/Jun/2012:11:22:31 +0200] "POST /myapp/methodX HTTP/1.1" 400 145 "-" "clientApp BlackBerry9930/7.1.0.402 VendorID/104" 10012667 
192.82.68.16 - - [25/Jun/2012:11:23:21 +0200] "POST /myapp/methodZ HTTP/1.1" 400 145 "-" "clientApp BlackBerry9930/7.1.0.402 VendorID/104" 10012562 

これらの要求に対してクライアントに送信されたステータスコード400 Bad Requestを確認できます。

行の終わりにある大きな数字(例:10012562)は、サーバー上でリクエストが処理された時間をマイクロ秒単位で示しています:10012562 =約10秒

接続が10秒後に何らかの理由で終了したように見えますか? AJP構成を調べましたが、タイムアウトは定義されていません。使用していない非同期要求のタイムアウトは10秒になります。

4

その理由を見つけました。 Apacheモジュールmod_reqtimeoutのデフォルト設定が原因で問題が発生しました:

<IfModule reqtimeout_module>

# mod_reqtimeout limits the time waiting on the client to prevent an
# attacker from causing a denial of service by opening many connections
# but not sending requests. This file tries to give a sensible default
# configuration, but it may be necessary to tune the timeout values to
# the actual situation. Note that it is also possible to configure
# mod_reqtimeout per virtual Host.


# Wait max 20 seconds for the first byte of the request line+headers
# From then, require a minimum data rate of 500 bytes/s, but don't
# wait longer than 40 seconds in total.
# Note: Lower timeouts may make sense on non-ssl virtual hosts but can
# cause problem with ssl enabled virtual hosts: This timeout includes
# the time a browser may need to fetch the CRL for the certificate. If
# the CRL server is not reachable, it may take more than 10 seconds
# until the browser gives up.
RequestReadTimeout header=20-40,minrate=500

# Wait max 10 seconds for the first byte of the request body (if any)
# From then, require a minimum data rate of 500 bytes/s
RequestReadTimeout body=10,minrate=500

</IfModule>

RIM BISインフラストラクチャを介してリクエスト本文を送信するのに時間がかかるため、BlackBerryクライアントの方がヒットする可能性が高いと思います。

値を100秒に設定し、クライアントが引き続き影響を受けるかどうかを監視します。

3

タイムアウトのように見えますが、Tomcatを介してRESTサービスに直接アクセスしようとしましたか?(そしてApache/ajpを通過しないでください)。これらの例外が発生しなくなったことがわかりますmayはApache2/mod_jkです。

以前の仕事で、いくつかのバージョンのmod_jkがApache2でうまく機能することを発見しました(もちろん、これを厳密なテストにかけたわけではありません。必要がないため、変更せずにどこでも機能するバージョンを使用しました)

0
gfountis