Detected duplicate HTTP-based FlexSessions, genera

2019-07-11 20:29发布

问题:

scene description: my program is implemented by flex+java+blazeDS+activeMQ,it subscribe the jms message from activeMQ by Flex Consumer,Currently i deliver two tomcat in the same Server,them are all contains my program ,and the ActiveMQ is in another server,now time i open the two applications in the same kind of browser,such as IE or Chrome,whatever,the url just like http://localhost:8080/HelloWord/index.html, http://localhost:8181/HelloWord/index.html

Problem: the first application url is http://localhost:8080/HelloWord/index.html, i open it in ie,and it can subscribe message very well,but when i open the second second application whose url is http://localhost:8181/HelloWord/index.html in ie, accident happens,two of the applications cannot subscribe message.

error log: 1.flex client log(flash.log): Detected duplicate HTTP-based FlexSessions, generally due to the remote host disabling session cookies. Session cookies must be enabled to manage the client connection correctly 2.java console log: flex.messaging.client.FlexClientNotSubscribedException: The client has no active subscriptions over endpoint 'my-polling-amf'. at flex.messaging.client.FlexClient.throwNotSubscribedException(FlexClient.java:1789) at flex.messaging.client.FlexClient.pollWithWait(FlexClient.java:967) at flex.messaging.endpoints.BasePollingHTTPEndpoint.handleFlexClientPoll(BasePollingHTTPEndpoint.java:538) at flex.messaging.endpoints.AbstractEndpoint.handleFlexClientPollCommand(AbstractEndpoint.java:1151) at flex.messaging.endpoints.AbstractEndpoint.serviceMessage(AbstractEndpoint.java:965) at flex.messaging.endpoints.AbstractEndpoint$$FastClassByCGLIB$$1a3ef066.invoke() at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:191) at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:692) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150) at org.springframework.flex.core.MessageInterceptionAdvice.invoke(MessageInterceptionAdvice.java:66) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.adapter.ThrowsAdviceInterceptor.invoke(ThrowsAdviceInterceptor.java:124) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.Cglib2AopProxy$FixedChainStaticTargetInterceptor.intercept(Cglib2AopProxy.java:576) at flex.messaging.endpoints.AMFEndpoint$$EnhancerByCGLIB$$3ae4b8ad.serviceMessage() at flex.messaging.endpoints.amf.MessageBrokerFilter.invoke(MessageBrokerFilter.java:103) at flex.messaging.endpoints.amf.LegacyFilter.invoke(LegacyFilter.java:158) at flex.messaging.endpoints.amf.SessionFilter.invoke(SessionFilter.java:44) at flex.messaging.endpoints.amf.BatchProcessFilter.invoke(BatchProcessFilter.java:67) at flex.messaging.endpoints.amf.SerializationFilter.invoke(SerializationFilter.java:166) at flex.messaging.endpoints.BaseHTTPEndpoint.service(BaseHTTPEndpoint.java:291) at flex.messaging.endpoints.AMFEndpoint$$EnhancerByCGLIB$$3ae4b8ad.service() at org.springframework.flex.servlet.MessageBrokerHandlerAdapter.handle(MessageBrokerHandlerAdapter.java:108) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:771) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:716) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:647) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:563) at javax.servlet.http.HttpServlet.service(HttpServlet.java:641) at javax.servlet.http.HttpServlet.service(HttpServlet.java:722) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:563) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:403) at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:286) at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:272) at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1730) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)

the test i have done: 1.FlexClient.getInstance().id = UIDUtil.createUID(); invalid 2.FlexClient.getInstance().id = null; invalid 3.use different kinds of browser,one use Ie,the other use Chrome, to open the two applications,them are ok; 4.one server one tomcat, use the same kind brower ie to open them ,them are ok; 5.use customer AMFChannel in flex MXML or the default AMFChannel definition in flex-config.xml, invalid;

network friends's advance: 1.http://blogs.adobe.com/lin/2011/05/duplication-session-error.html 2.http://stackoverflow.com/questions/7659775/duplicate-session-error-when-perform-proxy-lookup the two is invalid;

is there anybody meeting this situation before? any advice i will appreciate.

回答1:

Today I ran into a Flex Session Problem as well and encountered this SO question.

Well, the question is quite old, so I guess the original poster probably does not require any help any more, but for whoever stumbles across this post, I maybe the following info could help you.

A Flex App requires a valid session ID from the web app container (here tomcat), and it binds the clientOID found in the actual AMF request to this sessionID.

So the problem of the original poster probably was that he tried to use the same session ID on two tomcat instances, that will not work since every tomcat instance keeps the sessions for itself and in memory.

My problem was that I had a recorded jmeter test and it would not accept the combination of clientID in the recorded AMF message and sessionID in the URL. However, the AMF error message that is returned contains a valid new session ID in the header section. The AMF header of that error message looks like that (at least for me):

Version: 3
(Header #0 name=AppendToGatewayUrl, mustUnderstand=true)
 ";jsessionid=OLD_SESSION_ID;jsessionid=NEW_SESSION_ID"

So what I did is to extract the new session ID from the AMF header and used that for the rest of the requests.

hope this is useful to anyone...