大气框架中的长轮询间隔约为60秒。即使在AtmosphereRequest中设置pollingInterval属性后,请求也会在60秒后发送到服务器。如何在请求中设置pollingInterval?
这是javascript中的请求:
请求:{
url:document.location.toString()+'echo',
运输:'websocket',
fallbackTransport:'long-polling',
trackMessageLength:是的,
重新连接:是的,
pollingInterval:10,
maxReconnectOnClose:Number.MAX_VALUE,
reconnectInterval:10,
connectTimeout:-1
}
答案 0 :(得分:3)
在服务器端,在web.xml中,您可以设置这两个init-param条目:
<init-param>
<param-name>org.atmosphere.cpr.AtmosphereInterceptor</param-name>
<param-value>org.atmosphere.interceptor.HeartbeatInterceptor</param-value>
</init-param>
<init-param>
<param-name>org.atmosphere.interceptor.HeartbeatInterceptor.heartbeatFrequencyInSeconds</param-name>
<!-- value in seconds, default 60 -->
<param-value>10</param-value>
</init-param>
有关详细信息:http://atmosphere.github.io/atmosphere/apidocs/org/atmosphere/interceptor/HeartbeatInterceptor.html