Coder Social home page Coder Social logo

atmosphere-extensions's Introduction

Atmosphere Framework Extensions and Plugin

You need Atmosphere Runtime version 3.0.0 and higher to use those extension. To install, just do

     <dependency>
         <groupId>org.atmosphere</groupId>
         <artifactId>atmosphere-{atmosphere-module}</artifactId>
         <version>3.0.1</version>
      </dependency>

JDK11 JDK13

Easiest way to use extensions is by looking at our Samples or use ChatGPT!

atmosphere-extensions's People

Contributors

agherardi avatar christianekstrand avatar darrelk avatar dependabot[bot] avatar dyrkin avatar elakito avatar itd-sk avatar jccampanero avatar jfarcand avatar jimmyjim avatar jlleitschuh avatar jpomac avatar kambha avatar mikemosseri avatar pierreh avatar pjvds avatar pvorb avatar rasto68 avatar reda-alaoui avatar rgoldberg avatar rubyboy avatar ryan-za avatar seamusmac avatar sjardine avatar slovdahl avatar squinn avatar survivant avatar timofeevda avatar unbr8kbal avatar zenithar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

atmosphere-extensions's Issues

[Socket.IO] add endpoint support

in the current implementation, the endpoint are not supported.

That means that someone that subscribe to xxx:8080/chat

and xxx:8080/chat2

won't be dissociated.

Just add a little cache mechanics to split the both subscription.

PS. It's possible that the client will unsubscribed to one endpoint, so be sure to keep the sessionid into the cache for the others endpoints.

[Socket.IO] cache doesn't work in the samples

The cache is not working in the samples, because there isn't specified cache, so the default cache is used. The defaultCache doesn't cache anything :)

The feature must had been lost in the refactoring we did.

Use AtmosphereResource's UUID instead of connectionID

On Tue, Oct 16, 2012 at 9:45 PM, [email protected] wrote:
I noticed a possible issue with lookupResource for GWT. Currently in AtmosphereGwtHandler, the connectionID is pulled from the request in onRequest. That ID is then used for lookupResource to get the GwtAtmosphereResource.

I'm not sure if I am reading this wrong, but doesn't that allow for the client to spoof their connectionID when they are transmitting it to the server, thus hijacking another users session?

Wouldn't a better solution be to use the AtmosphereResource's uuid in onRequest instead of looking at the connectionID from the parameter?

Thanks,
Mike

Support for AMQP Broadcasters

Hello,

I've made a really beta version of RabbitMQ broadcaster support for Atmosphere.

https://github.com/Zenithar/atmosphere-amqp-rabbitmq

Not ready for a pull request, but I have a strange error, and not enough knowledge on Atmosphere to identify the real problem.

When using other transports no problem, but with WebSockets only the first call run successfully, and then when i try to broadcast other messages, the broadcaster is never called.

Regards.

[GWT] atmosphere gwt server 1.0.5 bug

In GwtAtmosphereResourceImpl there is a Serializer. In the Serializer.write(OutputStream, Object) there are some tests. First it is verified if object is an instance of Serializable, and if it is not it is verified if it is an instance of List. But implementations of List, like ArrayList, are also serializable. And because of this a list actually is treated as a serializable object. I think first it should be tested if an object is a List.

public void write(OutputStream out, Object o) throws IOException {
            if (o instanceof List) {
                List<?> list = (List) o;
                if (list.size() > 0) {
                    if (!(list.get(0) instanceof Serializable)) {
                        throw new IOException("Failed to write a list of objects that are not serializable");
                    }
                    try {
                        writer.write((List<Serializable>) o);
                    } catch (SerializationException ex) {
                        throw new IOException(ex);
                    }
                }
            } else if (o instanceof Serializable) {
                try {
                    writer.write((Serializable) o);
                } catch (IOException e) {
                    if (writer.isTerminated()) {
                        logger.debug("broadcast failed, connection terminated:" + e.getMessage(), e);
                    }
                    throw e;
                } catch (SerializationException e) {
                    throw new IOException(e);
                }
            } else {
                logger.warn("Failed to write an object that is not serializable");
            }
        }

[socket.io] doesn't support reading configuration from atmosphere.xml

SocketIOAtmosphereInterceptor only reads it's configuration values from from the servlet configuration and not from atmosphere.xml. This combined with the fact that the sane default provided in the code is overwritten with null when the property is read from the servlet config means that a value of null is returned to the browser when listing supported protocols. For example "234F8E29E4B88D8169C8203A805AFB3B34266E1D:15000:25000:null"

session-timeout=-1 && NO_TIMEOUT causes IllegalStateException

Config: GWT 2.5,atmosphere 1.1.0-SNAPSHOT,GlassFish 3.1.2.2(patched), websockets

When setting session-timout=-1 in web.xml as per servlet specification 3.0 section 7.5 for infinite duration of HTTP sessions, I encounter the below error when returning NO_TIMEOUT in my override of AtmosphereGwtHandler#doComet. My temporary workaround is to return -2 instead. Apparently the atmosphere framework asserts SUSPEND_TIMEOUT <= session-timeout somewhere in its code. My intention is to programmatically expire sessions in my AtmosphereGwtHandler#cometTerminated override, in a pure websocket setup. Hence my setting of either value to conceptual infinity.

SEVERE: at org.atmosphere.cpr.AtmosphereResourceImpl.suspend(AtmosphereResourceImpl.java:344)
SEVERE: at org.atmosphere.gwt.server.impl.GwtAtmosphereResourceImpl.suspend(GwtAtmosphereResourceImpl.java:173)
SEVERE: at org.atmosphere.gwt.server.AtmosphereGwtHandler.doCometImpl(AtmosphereGwtHandler.java:509)
SEVERE: at org.atmosphere.gwt.server.AtmosphereGwtHandler.onRequest(AtmosphereGwtHandler.java:235)
SEVERE: at org.atmosphere.cpr.AsynchronousProcessor.action(AsynchronousProcessor.java:267)
SEVERE: at org.atmosphere.cpr.AsynchronousProcessor.suspended(AsynchronousProcessor.java:166)
SEVERE: at org.atmosphere.container.GlassFishWebSocketSupport.service(GlassFishWebSocketSupport.java:68)
SEVERE: at org.atmosphere.cpr.AtmosphereFramework.doCometSupport(AtmosphereFramework.java:1370)
SEVERE: at org.atmosphere.websocket.DefaultWebSocketProcessor.dispatch(DefaultWebSocketProcessor.java:359)
SEVERE: at org.atmosphere.websocket.DefaultWebSocketProcessor.open(DefaultWebSocketProcessor.java:144)
SEVERE: at org.atmosphere.container.GlassFishWebSocketHandler.onConnect(GlassFishWebSocketHandler.java:76)
SEVERE: at com.sun.grizzly.websockets.DefaultWebSocket.onConnect(DefaultWebSocket.java:140)
SEVERE: at com.sun.grizzly.websockets.WebSocketEngine.upgrade(WebSocketEngine.java:189)
SEVERE: at com.sun.grizzly.websockets.WebSocketAsyncFilter.doFilter(WebSocketAsyncFilter.java:54)
SEVERE: at com.sun.grizzly.arp.DefaultAsyncExecutor.invokeFilters(DefaultAsyncExecutor.java:171)
SEVERE: at com.sun.grizzly.arp.DefaultAsyncExecutor.interrupt(DefaultAsyncExecutor.java:143)
SEVERE: at com.sun.grizzly.arp.AsyncProcessorTask.doTask(AsyncProcessorTask.java:102)
SEVERE: at com.sun.grizzly.http.TaskBase.run(TaskBase.java:193)
SEVERE: at com.sun.grizzly.http.TaskBase.execute(TaskBase.java:175)
SEVERE: at com.sun.grizzly.arp.DefaultAsyncHandler.handle(DefaultAsyncHandler.java:145)
SEVERE: at com.sun.grizzly.arp.AsyncProtocolFilter.execute(AsyncProtocolFilter.java:210)
SEVERE: at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
SEVERE: at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
SEVERE: at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
SEVERE: at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
SEVERE: at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
SEVERE: at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
SEVERE: at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
SEVERE: at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
SEVERE: at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
SEVERE: at java.lang.Thread.run(Thread.java:722)
SEVERE: 34430 [http-thread-pool-8080(2)] WARN org.atmosphere.websocket.protocol.SimpleHttpProtocol - java.lang.IllegalStateException: Cannot suspend a response longer than the session timeout. Increase the value of session-timeout in web.xml Status 500 Message Server Error

SEVERE: 64347 [http-thread-pool-8080(1)] INFO com.mousepilots.web.server.atmosphere.AtmosphereCometHandler - Failed to find resource for [09c8c951-fad2-4fa5-87d9-228022b65189]

Otherwise thanks a lot for this great framework!

Jurjen

Support for Hazelcast v2.3.1

Hi,

The current Atmosphere Hazelcast plugin do work with Hazelcast version 2.3.1. To solve it, I had to change the version number in the pom file and add the following lines to the HazelcastBroadcaster.java

...
[modified] private ITopic topic;

 public void setUp() {
    topic = Hazelcast.<String>getTopic(getID());
    topic.addMessageListener(new MessageListener<String>() {

        @Override
[modified]  public void onMessage(Message<String> message) {
[modified]  broadcastReceivedMessage(message.getMessageObject());
        }
    });
}

...

Best regards,

Jone

[GWT] Atmosphere not working with IE8 - contentWindow undefined error

Atmosphere is not working with IE8. I'm trying to receive a message broadcasted at the server and there is a javascript error at following code:

  function maybeInjectFrame(){
    if (!frameInjected) {
      frameInjected = true;
      var iframe = $doc.createElement($intern_36);
      iframe.src = $intern_37;
      iframe.id = $intern_1;
      iframe.style.cssText = $intern_38;
      iframe.tabIndex = -1;
      $doc.body.appendChild(iframe);
      $stats && $stats({moduleName:$intern_1, sessionId:$sessionId, subSystem:$intern_2, evtGroup:$intern_8, millis:(new Date).getTime(), type:$intern_39});
      iframe.contentWindow.location.replace(base + initialHtml);
    }
  }

Error occurs at last line, the iframe.contentWindow is undefined. The pasted code is in Module.nocache.js file.

GwtAtmosphereResourceImpl has IllegalStateException in v1.0.3

We are seeing this error using 1.0.3 when we have multiple clients (Firefox 16.0.2). Server is JBoss 7.x.

Why is this happening? And we would like to have the transport variable added to the IllegalStateException message so we can better determine what is happening here.

11:16:01,332 ERROR org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/web-dashboard].[AtmosphereServlet] Servlet.service() for servlet AtmosphereServlet threw exception: java.lang.IllegalStateException: Failed to determine responsewriter
at org.atmosphere.gwt.server.impl.GwtAtmosphereResourceImpl.createResponseWriter(GwtAtmosphereResourceImpl.java:248) [atmosphere-gwt-server-1.0.3.jar:1.0.3]
at org.atmosphere.gwt.server.impl.GwtAtmosphereResourceImpl.(GwtAtmosphereResourceImpl.java:59) [atmosphere-gwt-server-1.0.3.jar:1.0.3]
at org.atmosphere.gwt.server.AtmosphereGwtHandler.onRequest(AtmosphereGwtHandler.java:231) [atmosphere-gwt-server-1.0.3.jar:1.0.3]
at org.atmosphere.cpr.AsynchronousProcessor.action(AsynchronousProcessor.java:256) [atmosphere-runtime-1.0.3.jar:1.0.3]
at org.atmosphere.cpr.AsynchronousProcessor.suspended(AsynchronousProcessor.java:166) [atmosphere-runtime-1.0.3.jar:1.0.3]
at org.atmosphere.container.Servlet30CometSupport.service(Servlet30CometSupport.java:101) [atmosphere-runtime-1.0.3.jar:1.0.3]
at org.atmosphere.cpr.AtmosphereFramework.doCometSupport(AtmosphereFramework.java:1292) [atmosphere-runtime-1.0.3.jar:1.0.3]
at org.atmosphere.cpr.AtmosphereServlet.doPost(AtmosphereServlet.java:293) [atmosphere-runtime-1.0.3.jar:1.0.3]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:754) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:489) [jbossweb-7.0.13.Final.jar:]
at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153) [jboss-as-web-7.1.1.Final.ISS.1.jar:]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.13.Final.jar:]
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.13.Final.jar:]
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) [jbossweb-7.0.13.Final.jar:]
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930) [jbossweb-7.0.13.Final.jar:]
at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_07]

[GWT] IllegalStateException when using SessionBroadcasterCache with Atmosphere GWT

Hi there,

I am using a gwt atmosphere extension (version 1.1.0 beta2) in my application.
Since we use Spring and Spring does not support WebSocket yet, I have disabled it in the configurations.
Furthermore, not using web sockets means that long polling has to work very reliably. So I set the BroadcasterCache to the SessionBroadcasterCache (HeaderBroadcasterCache won't work yet with gwt see issue #14 ).
Unfortunately when I log out from the session, Atmosphere does not consider this and I get following errors:

01/18 13:54:50.027 [/atmosphereGwt-AsyncWrite-16] [n/a] WARN o.atmosphere.cpr.DefaultBroadcaster - This message Import.ImportJobStateChanged will be lost, adding it to the BroadcasterCache
01/18 13:54:50.029 [/atmosphereGwt-BroadcasterConfig-17] [n/a] WARN o.atmosphere.cpr.DefaultBroadcaster - Unable to track messages Import.ImportJobStateChanged
java.lang.IllegalStateException: setAttribute: Session [151FF3FB3BD6D539AD7322A8D7051079] has already been invalidated
    at org.apache.catalina.session.StandardSession.setAttribute(StandardSession.java:1437) ~[catalina.jar:7.0.27]
    at org.apache.catalina.session.StandardSession.setAttribute(StandardSession.java:1402) ~[catalina.jar:7.0.27]
    at org.apache.catalina.session.StandardSessionFacade.setAttribute(StandardSessionFacade.java:156) ~[catalina.jar:7.0.27]
    at org.atmosphere.cache.SessionBroadcasterCache.addToCache(SessionBroadcasterCache.java:88) ~[atmosphere-runtime-1.1.0.beta2.jar:1.1.0.beta2]
    at org.atmosphere.cpr.DefaultBroadcaster.trackBroadcastMessage(DefaultBroadcaster.java:936) [atmosphere-runtime-1.1.0.beta2.jar:1.1.0.beta2]
    at org.atmosphere.cpr.DefaultBroadcaster.perRequestFilter(DefaultBroadcaster.java:813) [atmosphere-runtime-1.1.0.beta2.jar:1.1.0.beta2]
    at org.atmosphere.cpr.DefaultBroadcaster.deliverPush(DefaultBroadcaster.java:738) [atmosphere-runtime-1.1.0.beta2.jar:1.1.0.beta2]
    at org.atmosphere.cpr.DefaultBroadcaster.push(DefaultBroadcaster.java:649) [atmosphere-runtime-1.1.0.beta2.jar:1.1.0.beta2]
    at org.atmosphere.cpr.DefaultBroadcaster$2.run(DefaultBroadcaster.java:526) [atmosphere-runtime-1.1.0.beta2.jar:1.1.0.beta2]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441) [na:1.6.0_35]
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) [na:1.6.0_35]
    at java.util.concurrent.FutureTask.run(FutureTask.java:138) [na:1.6.0_35]
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [na:1.6.0_35]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [na:1.6.0_35]
    at java.lang.Thread.run(Thread.java:662) [na:1.6.0_35]

So I tried implementing my own BroadcasterCache:

public class SessionAwareSessionBroadcasterCache extends SessionBroadcasterCache {

  @Override
  public void addToCache( String broadcasterId, AtmosphereResource resource, Message message ) {
    if ( resource.getRequest().isRequestedSessionIdValid() ) {
      //log info
      super.addToCache( broadcasterId, resource, message );
    } else {
      //log warning
    }
  }
  
}

But the statement

resource.getRequest().isRequestedSessionIdValid()
is never true and occassionaly I get the following error:

01/22 14:05:50.225 [/atmosphereGwt-BroadcasterConfig-0] [n/a] WARN c.h.h.c.u.s.SessionAwareSessionBroadcasterCache - Session invalid, do not add to cache
01/22 14:05:50.229 [/atmosphereGwt-AsyncWrite-4] [n/a] WARN o.a.h.AbstractReflectorAtmosphereHandler - Serializer exception: message: 4dc5bdb9-edc8-4edf-8833-ab478326d8c9
org.apache.catalina.connector.ClientAbortException: null
    at org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:346) ~[catalina.jar:7.0.27]
    at org.apache.catalina.connector.OutputBuffer.flush(OutputBuffer.java:306) ~[catalina.jar:7.0.27]
    at org.apache.catalina.connector.CoyoteOutputStream.flush(CoyoteOutputStream.java:101) ~[catalina.jar:7.0.27]
    at org.atmosphere.gwt.server.impl.CountOutputStream.flush(CountOutputStream.java:79) ~[atmosphere-gwt-server-1.1.0.beta2.jar:1.1.0.beta2]
    at org.atmosphere.gwt.server.deflate.DeflaterOutputStream.flush(DeflaterOutputStream.java:108) ~[atmosphere-gwt-server-1.1.0.beta2.jar:1.1.0.beta2]
    at sun.nio.cs.StreamEncoder.implFlush(StreamEncoder.java:278) ~[na:1.6.0_35]
    at sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:122) ~[na:1.6.0_35]
    at java.io.OutputStreamWriter.flush(OutputStreamWriter.java:212) ~[na:1.6.0_35]
    at org.atmosphere.gwt.server.impl.GwtResponseWriterImpl.flush(GwtResponseWriterImpl.java:261) ~[atmosphere-gwt-server-1.1.0.beta2.jar:1.1.0.beta2]
    at org.atmosphere.gwt.server.impl.GwtResponseWriterImpl.heartbeat(GwtResponseWriterImpl.java:250) ~[atmosphere-gwt-server-1.1.0.beta2.jar:1.1.0.beta2]
    at org.atmosphere.gwt.server.impl.ManagedStreamResponseWriter.heartbeat(ManagedStreamResponseWriter.java:92) ~[atmosphere-gwt-server-1.1.0.beta2.jar:1.1.0.beta2]
    at org.atmosphere.gwt.server.impl.GwtResponseWriterImpl.write(GwtResponseWriterImpl.java:226) ~[atmosphere-gwt-server-1.1.0.beta2.jar:1.1.0.beta2]
    at org.atmosphere.gwt.server.impl.ManagedStreamResponseWriter.write(ManagedStreamResponseWriter.java:86) ~[atmosphere-gwt-server-1.1.0.beta2.jar:1.1.0.beta2]
    at org.atmosphere.gwt.server.impl.GwtResponseWriterImpl.write(GwtResponseWriterImpl.java:204) ~[atmosphere-gwt-server-1.1.0.beta2.jar:1.1.0.beta2]
    at org.atmosphere.gwt.server.impl.GwtAtmosphereResourceImpl$3.write(GwtAtmosphereResourceImpl.java:300) ~[atmosphere-gwt-server-1.1.0.beta2.jar:1.1.0.beta2]
    at org.atmosphere.handler.AbstractReflectorAtmosphereHandler.onStateChange(AbstractReflectorAtmosphereHandler.java:100) ~[atmosphere-runtime-1.1.0.beta2.jar:1.1.0.beta2]
    at org.atmosphere.cpr.DefaultBroadcaster.invokeOnStateChange(DefaultBroadcaster.java:944) [atmosphere-runtime-1.1.0.beta2.jar:1.1.0.beta2]
    at org.atmosphere.cpr.DefaultBroadcaster.executeAsyncWrite(DefaultBroadcaster.java:866) [atmosphere-runtime-1.1.0.beta2.jar:1.1.0.beta2]
    at org.atmosphere.cpr.DefaultBroadcaster$3.run(DefaultBroadcaster.java:567) [atmosphere-runtime-1.1.0.beta2.jar:1.1.0.beta2]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441) [na:1.6.0_35]
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) [na:1.6.0_35]
    at java.util.concurrent.FutureTask.run(FutureTask.java:138) [na:1.6.0_35]
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [na:1.6.0_35]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [na:1.6.0_35]
    at java.lang.Thread.run(Thread.java:662) [na:1.6.0_35]
Caused by: java.io.IOException: null
    at org.apache.coyote.http11.InternalAprOutputBuffer.flushBuffer(InternalAprOutputBuffer.java:205) ~[tomcat-coyote.jar:7.0.27]
    at org.apache.coyote.http11.InternalAprOutputBuffer.flush(InternalAprOutputBuffer.java:109) ~[tomcat-coyote.jar:7.0.27]
    at org.apache.coyote.http11.AbstractHttp11Processor.action(AbstractHttp11Processor.java:789) ~[tomcat-coyote.jar:7.0.27]
    at org.apache.coyote.Response.action(Response.java:174) ~[tomcat-coyote.jar:7.0.27]
    at org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:341) ~[catalina.jar:7.0.27]
    ... 24 common frames omitted

Note that atmosphere tries to make a async write though I have disabled that support.

In my web.xml part for atmosphere looks I have

  • disabled async-supported and also
  • disabled useWebSocket and
  • org.atmosphere.disableOnStateEvent is set to true

My AtmosphereGwtHandler:

public class HSPAtmosphereGwtHandler extends AtmosphereGwtHandler {
  private static final int TIMEOUT = 120 * 60 * 1000;

  private static final String COMET_ID = HSPAtmosphereGwtHandler.class.getName() + "#cometResponseId";
  
  interface BroadcasterFactoryProvider {
    BroadcasterFactory getFactory();
  }
  
  private static class AtmosphereResponseWriter implements CometWriter {

    GwtAtmosphereResource resource;
    
    public AtmosphereResponseWriter( GwtAtmosphereResource resource ) {
      this.resource = resource;
    }
    
    @Override
    public void write( String message ) {
      if( !receiverIsCurrentUser() ) {
        resource.getBroadcaster().broadcast( message, resource.getAtmosphereResource() );
      }
    }
    private boolean receiverIsCurrentUser() {
      boolean result = false;
      HttpServletRequest request = RequestFactoryServlet.getThreadLocalRequest();
      // If started from a QuartzJob, no request exists
      if( requestExists( request ) ) {
        String currentCometId = ( String )request.getSession().getAttribute( COMET_ID );
        String receiverCometId = resource.getConnectionUUID();
        result = receiverCometId.equals( currentCometId );
      }
      return result;
    }
    
    private static boolean requestExists( HttpServletRequest request ) {
      return request != null;
    }
  }
  
  private static final Logger LOG = LoggerFactory.getLogger( HSPAtmosphereGwtHandler.class );
  
  CometRegistration cometService;
  Broadcaster broadcaster;
  BroadcasterFactoryProvider broadcasterFactoryProvider;
  
  public HSPAtmosphereGwtHandler() {
    this.broadcasterFactoryProvider = new BroadcasterFactoryProvider() {
      @Override
      public BroadcasterFactory getFactory() {
        return BroadcasterFactory.getDefault();
      }
    };
  }
  
  @Override
  public void init( ServletConfig servletConfig ) throws ServletException {
      super.init( servletConfig );
      cometService = getBeanFromContext( CometRegistration.class );
      String eventSpace = getEventSpace();
      broadcaster = getBroadcasterFactory().lookup( eventSpace, true );
  }
  
  @Override
  public int doComet( GwtAtmosphereResource resource ) throws ServletException, IOException {
    resource.getAtmosphereResource().setBroadcaster( broadcaster );
    String connectionId = resource.getConnectionUUID();
    resource.getRequest().getSession().setAttribute( COMET_ID, connectionId );
    cometService.sessionCreated( connectionId, new AtmosphereResponseWriter( resource ) );
    return TIMEOUT;
  }
  
  @Override
  public void terminate( GwtAtmosphereResource cometResponse, boolean serverInitiated ) {
    String sessionId = cometResponse.getConnectionUUID();
    cometService.sessionDestroyed( sessionId );
    LOG.debug( "Atmosphere session destroyed at cometService with id " + sessionId );
  }
  
  BroadcasterFactory getBroadcasterFactory() {
    return broadcasterFactoryProvider.getFactory();
  }

  private String getEventSpace() {
    return "/atmosphereGwt";
  }
  
  private  T getBeanFromContext( Class clazz ) {
    return ApplicationContextUtils.getUniqueBean( getWebApplicationContext(), clazz );
  }
  
  private WebApplicationContext getWebApplicationContext() {
    return WebApplicationContextUtils.getWebApplicationContext( getServletContext() );
  }
  
}

Thanks in advance for any help.

[Socket.IO] add delaying sent message on polling connection

Should wait a little before sending message to client on a pooling connection. With a pooling connection, the connection is resume server side when a message is sent.

Is possible that multiple messages to be sent in the SocketIOHandler, so we need to support that transparently for the user

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.