2017-09-29 12 views
0

Apache Tomcat Server(8.0.39)のセッションタイムアウトが30分(web.xmlで設定)になっているため、30秒後に切断されたWebocketを停止するように設定できません分。ランタイム2.4.8とJavascript 2.3.5を使用するAtmospheric websocket Tomcat8によって切断されました

私が手のメッセージは次のとおりです。

Websocket closed, reason: This connection was established under an 
authenticated HTTP session that has ended. - wasClean: true 

Atmosphere: Firing onClose (closed case) 

reasonPhrase:"maxReconnectOnClose reached" 

私はクライアントとサーバーの両方のハートビートを使用しています。サーバーは60秒ごとにハートビートを送信しますが、これはTomcatセッションが30分でタイムアウトするのを止めるものではありません。

ここで概説として私はMAX_INACTIVITYを使用して試してみた:

https://github.com/Atmosphere/atmosphere/issues/2250

<init-param> 
<param-name>org.atmosphere.cpr.AtmosphereInterceptor</param-name> 
<param-value>o.a.interceptor.IdleResourceInterceptor</param-value> 
</init-param> 

<init-param> 
    <param-name>org.atmosphere.cpr.session.maxInactiveInterval</param-name> 
    <param-value>3600000</param-value> 
</init-param> 

<init-param> 
    <param-name>o.a.cpr.CometSupport.maxInactiveActivity</param-name> 
    <param-value>3600000</param-value> 
</init-param> 

しかし、これも同様に無視され、TomcatがWebSocketをを閉じます。

AtmosphereでHttpセッションに触れ、Webソケットを閉じるのを止める方法はありますか?

基本設定:

@WebSocketHandlerService(path = "/async/chat", broadcasterCache = 
UUIDBroadcasterCache.class) 
public class ChatServer extends WebSocketHandlerAdapter {} 

Javascriptを:

request.url = 'async/chat'; 
    request.contentType = 'application/json'; 
    request.transport = 'websocket'; 
    request.fallbackTransport = 'websocket'; 
    request.maxReconnectOnClose = 5; 
    request.enableProtocol = true; 
    request.trackMessageLength = true; 
    request.timeout = 3600000; 
    request.logLevel = 'debug'; 

のweb.xml:

<servlet> 
<description>AtmosphereServlet</description> 
<servlet-name>AtmosphereServlet</servlet-name> 
<servlet-class>org.atmosphere.cpr.AtmosphereServlet</servlet-class> 

<init-param> 
<param-name>org.atmosphere.cpr.packages</param-name> 
<param-value>atnf.jportal.websocket</param-value> 
</init-param> 

<init-param> 
<param-name>org.atmosphere.cpr.AtmosphereInterceptor</param-name> 
<param-value>o.a.client.TrackMessageSizeInterceptor</param-value> 
</init-param> 

<init-param> 
<param-name> 
o.a.i.HeartbeatInterceptor.clientHeartbeatFrequencyInSeconds 
</param-name>  
<param-value>120</param-value> 
</init-param> 

<async-supported>true</async-supported>   

</servlet> 

<servlet-mapping> 
<servlet-name>AtmosphereServlet</servlet-name> 
<url-pattern>/async/*</url-pattern> 
</servlet-mapping> 

答えて

0

デフォルトでは、Tomcatのインストールは30分の期間の後にすべてのセッションを閉じました。大量のWebソケット実装では、クライアント/サーバがHeartbeatInterceptorを使用してハートビートを送信しても、このタイムアウトによってすべてのWebソケットが閉じられます。

緩和計画では、アプリケーションのweb.xmlファイルに無制限のタイムアウトを設定するだけでしたが、これによって古いセッションが残っていました。少し掘り下げた後、大気の接続が存在する場合、セッションの最大非アクティブ間隔を-1に設定するように設定することができます。 web.xmlに

<init-param> 
    <param-name>org.atmosphere.cpr.removeSessionTimeout</param-name> 
    <param-value>true</param-value> 
</init-param> 

自体ことで、これは無限のタイムアウトを持っているのセッションを有効にしません、あなたはまた、それぞれ、リスナーに有効以上により

<listener> 
    <listener-class>org.atmosphere.cpr.SessionSupport</listener-class> 
</listener> 

を有効にする必要がありますセッションには次の属性/プロパティが割り当てられます。

name: atmosphere.session.timeout.restorer 
type: org.atmosphere.cpr.SessionTimeoutRestorer 
value: SessionTimeoutRestorer[timeout=1800, requestCount=4] 

pplicationはこの属性を削除し、残りのセッションにタイムアウト(30分のデフォルト設定)を割り当てます。

  • Spring Securityは既存のセッションを閉じ、新しいセッションを作成します(タイムアウトを有効にします)。
関連する問題