Git Product home page Git Product logo

cometd's Introduction

The CometD Project

Welcome to the CometD Project, a scalable comet (server push) implementation for the web.

CometD Versions

CometD Version Min Java Version Min Jetty Version Servlet APIs
7.0.x Java 11 Jetty 11.0.x jakarta.servlet.*
6.0.x Java 11 Jetty 10.0.x javax.servlet.*
5.0.x Java 8 Jetty 9.4.x javax.servlet.*

CometD License

The CometD source code is released under the Apache 2.0 License.

Project Directory Layout

cometd-archetypes    - The Maven archetypes for quick application development
cometd-demo          - Demo of the Java server and of the Dojo/jQuery clients
cometd-documentation - The CometD documentation
cometd-java          - The Java server and java client libraries
cometd-javascript    - The JavaScript (Dojo/jQuery) client libraries

Running the CometD Demo

If you have downloaded the release bundle, then the CometD is already built for you. To run the demonstration with Maven, unzip the release bundle and execute:

$ cd cometd-demo
$ mvn jetty:run

then point your browser at http://localhost:8080

Alternately you can deploy the CometD demo war file into any Servlet 2.5 or later server (e.g. jetty, tomcat, glassfish) with commands like:

$ cp cometd-demo/target/cometd-demo/target/cometd-demo-*.war  $MY_SERVER/webapps/cometd.war
cd $MY_SERVER
<command to run my server>

Reporting Issues

Issues, bugs and requests for enhancements should be filed at https://bugs.cometd.org

Building CometD

If you have cloned the source release, follow the instructions at https://docs.cometd.org/current/reference/#_build, or just do:

$ mvn install

CometD Benchmark

The CometD Benchmark can be run interactively or in batch mode.

To run the server interactively, open a terminal window and type:

$ cd cometd-java/cometd-java-benchmark/cometd-java-benchmark-server/
$ mvn exec:exec

Then follow the instructions printed in the terminal.

To run the client interactively, open another terminal window (potentially on another machine), and type:

$ cd cometd-java/cometd-java-benchmark/cometd-java-benchmark-client/
$ mvn exec:exec

Then follow instructions printed on the terminal to generate the load.

cometd's People

Contributors

davidascher avatar dependabot[bot] avatar diagoras avatar dylans avatar earcam avatar fabriziocucci avatar gregw avatar innerverse avatar jmcc0nn3ll avatar joakime avatar joejackson1993 avatar lachlan-roberts avatar lorban avatar mathieucarbou avatar mrossi975 avatar nathklei avatar olamy avatar phiggins42 avatar rocketraman avatar sbordet avatar slightlyoff avatar szegedi avatar xantus avatar zaynetro 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  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  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

cometd's Issues

org.eclipse.jetty.io.EofException message after running for some days with the BayeuxClient.java

[2009-11-02 14:01:24,810 WARN ] [HttpClient-11] [org.eclipse.jetty.util.log.Slf4jLog:91] EXCEPTION on HttpExchange@29759410=POST//preprod.qnh-ajt.eu:80/groundcontrol/cometd/publish4
org.eclipse.jetty.io.EofException
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:310)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:203)
at org.eclipse.jetty.client.HttpConnection.handle(HttpConnection.java:271)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:438)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:435)
at java.lang.Thread.run(Thread.java:619)
[2009-11-02 14:01:24,841 WARN ] [HttpClient-11] [org.eclipse.jetty.util.log.Slf4jLog:78] org.cometd.client.BayeuxClient@ba5c7a: org.eclipse.jetty.io.EofException
[2009-11-02 14:01:24,841 WARN ] [HttpClient-11] [org.eclipse.jetty.util.log.Slf4jLog:78] IOE on HttpExchange@29759410=POST//preprod.qnh-ajt.eu:80/groundcontrol/cometd/publish9

Implement synchronous disconnect

It would be useful to have a synchronous disconnect() to be invoked from onunload browser handlers.
Having it synchronous will make the browser wait until the response arrives and will avoid (hopefully) that the browser kills the javascript runtime before the disconnect hits the network.
For the implementation, it can rely on XHR.open(method, url, async).

Reload extension is broken

The reload extension functionality is broken in several ways.

The server is not able to handle an outstanding connect followed by another connect; this is a side effect of the changes that were introduced by fixing #40 in ContinuationClient.

The JavaScript client starts an internal batch during the handshake request; this internal batch is ended on the first successful connect response. However, even though the reload extension does replay the handshake response, it does not have the typical "connect-request + connect-response + connect-request" cycle of a normal handshake; it only has "connect-request". Therefore the internal batch is not ended until the connect returns, which only happens after the long poll timeout. This causes the application to seem hung until the connect returns.

Error in BayeuxService.doInvoke() Logic

BayeuxService.doInvoke() incorrectly identifies the parameter type for subscription callbacks with the following signature by testing the type of the second parameter instead of the third to see if it implements Message.

method(Client, String, Message, String).

I've attached a diff to solve the issue.

Document more Spring integration patterns for Bayeux services

When using Spring along with other frameworks (such as, for example, Struts2), the strategy of overriding Spring's default loading mechanism may not work, because the framework may need to initialize Spring before the CometD servlet.

For example, Struts2 is configured via a servlet filter which cannot be configured using <load-on-startup> to be initialized after the CometD servlet. When Struts2 is integrated with Spring, initialization of the Struts2 filter triggers Spring initialization.

Document the pattern of using lazy initialization for Bayeux services.

Publish() can send messages with null clientId

In case the server disconnects, the long poll is returned with an advice to re-handshake.
Re-handshaking implies that the clientId is nulled out, so any publish() between the re-handshake request and a successful re-handshake response will be sent without clientId.

Long polling transport does not timeout when network fails

When using long polling transport, and the network cable is unplugged, the client cannot detect that the communication with the server has been interrupted.
This leaves the client in an inconsistent state, while the server normally times out the client.
On later re-plug of the cable, the client is not able to reconnect properly to the server.

java BayeuxClient, RemoveListener never called

For our open source product we depend on getting information on connection problems, so we can reinit the connection. We tried to add a RemoveListener, but this listner is never called (when you look at the BayeuxClient.java), it is only added to the list of removeListeners.

Definition of timeout advice for long polling response

[Ticket raised following thread at http://groups.google.com/group/cometd-dev/browse_thread/thread/3afa4e0a3d632d10]

The long-polling response includes a "timeout" advice field, indicating the maximum time before a long-poll completes. This field should be documented in the spec. (e.g. section 6.1.2, "long-polling response messages").

Relax immutability of handshake extra object

Any extra object passed to handshake() is saved so that it can be used in case of automatic reconnects.
However, a deep copy of the object is made, so that modifications to the extra handshake object are not used in a subsequent reconnect.
Given that using extensions it is always possible to customize the handshake message (or even replace it completely with another), having the extra handshake object immutable is just a complication for users.

cometd-twisted server return broken answers

when i send request:
[{"channel":"/meta/subscribe","subscription":"/chat/demo","id":3,"clientId":"fuUU0LSBqoDCMI7Wzx9PozKseAdZoX8uFPkB2QF"},{"channel":"/meta/subscribe","subscription":"/chat/members","id":4,"clientId":"fuUU0LSBqoDCMI7Wzx9PozKseAdZoX8uFPkB2QF"},{"channel":"/service/members","data":{"user":"mico","room":"/chat/demo"},"id":5,"clientId":"fuUU0LSBqoDCMI7Wzx9PozKseAdZoX8uFPkB2QF"},{"channel":"/chat/demo","data":{"user":"mico","membership":"join","chat":"mico has joined"},"id":6,"clientId":"fuUU0LSBqoDCMI7Wzx9PozKseAdZoX8uFPkB2QF"}]

i have received:
[{"successful": true, "clientId": "fuUU0LSBqoDCMI7Wzx9PozKseAdZoX8uFPkB2QF", "channel": "/meta/subscribe"}, {"successful": true, "clientId": "fuUU0LSBqoDCMI7Wzx9PozKseAdZoX8uFPkB2QF", "channel": "/meta/subscribe"}, {"successful": true, "id": 5, "channel": "/service/members"}, {"successful": true, "id": 6, "channel": "/chat/demo"}]

there is no 'id' and 'subscription' fields at first and second answers.

JavaScript library must check input arguments validity

It is very easy to make the server fail when, from the JS client, calls to the public methods are made without the required parameters.

cometd.publish(); // Missing channel and data

results in:

java.lang.NullPointerException
    at org.cometd.server.AbstractBayeux.handle(AbstractBayeux.java:282)

and

cometd.publish({}); // Missing channel

results in:

java.lang.Error
    at org.cometd.server.AbstractCometdServlet.getMessages(AbstractCometdServlet.java:322)
    ...
    at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.ClassCastException: java.util.HashMap cannot be cast to java.lang.String
    at org.cometd.server.MessageImpl.put(MessageImpl.java:258)

And a moment later the connect fails with a JSON parsing error (this may be another bug in the server side):

java.lang.Error
    at org.cometd.server.AbstractCometdServlet.getMessages(AbstractCometdServlet.java:322)
    ....
    at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.IllegalStateException: unknown char ','(44) in org.eclipse.jetty.util.ajax.JSON$ReaderSource@3085a863
    at org.eclipse.jetty.util.ajax.JSON.handleUnknown(JSON.java:807)

Checks should be performed in the client to avoid these problems, as people monitor their server and can worry seeing these errors.

Add support for async/sync message delivery to BayeuxClient

This tracks jetty issue http://jira.codehaus.org/browse/JETTY-1162.

In jetty-6, message notification to message listeners inside the deliver(Client from, Message message) always happens inside the sync block on the _inQ. This was changed to be more like the server-side clients, with the use of Async and Sync MessageListeners.

The org.cometd version of BayeuxClient always delivers all messages outside of the sync block, however it may be a good idea to introduce the Sync MessageListener to allow for sync delivery.

Long poll stops if the webapp is hot redeployed

Running the cometd-demo via the Jetty Maven plugin, then touching the web.xml file to cause a hot redeploy, causes the long poll to stop.
Seems like the webapp redeploys, but the long poll is not resumed until it times out, and then it returns with an empty body that causes the client to abort (as it does not understand an empty JSON response).

Allow easier handshake response customization

See http://jira.codehaus.org/browse/JETTY-875.

When the Bayeux policy denies the handshake, it normally would want to customize the response's advice to set (at least) reconnect: "none", but possibly also the reason for the deny so that the client can inform the user.

In CometD 1 doing this was possible using an extension, but it was a bit cumbersome and required intimate knowledge of the times at which the policy and extensions were called.
The goal is to make is simpler for CometD 2.

Add type of cometd message to url for javascript clients.

The java-client appends the type of the cometd message to the url, eg handshake, publish, connect. This allows the server-side to apply standard servlet filters with url pattern matching and it would be good to be able to do this with the javascript client as well.

jquery-json should be updated to newer version

The jquery-json plugin used by Cometd's javascript-jquery component was updated in August with a version which supports browsers with built-in JSON support. Native browser JSON methods are significantly faster than ones written in Javascript.

javascript-jquery should not be using raw "eval" for JSON

The "evalJSON" method from the jquery-json library performs an unchecked "eval" on the supplied string, potentially opening up a variety of security concerns. The same library also offers a "secureEvalJSON" method which uses regexes to ensure that the code cannot be malicious (contain function calls, etc.) before executing it. Attached is a patch against /trunk/cometd-javascript@787

NPE in TimesyncExtension

It may happen that the offset is absent or NaN, and in both cases would return null in TimesyncExtension, line 154.

ClientAdded listeners called from inside constructor of ClientImpl leads to NullPointerException

java.lang.NullPointerException
at org.mortbay.cometd.continuation.ContinuationClient.lazyResume(ContinuationClient.java:132)
at org.mortbay.cometd.ClientImpl.doDelivery(ClientImpl.java:188)
at org.mortbay.cometd.ClientImpl.deliverLazy(ClientImpl.java:130)
at com.chess.live.AbstractService.send(AbstractService.java:367)
at com.chess.live.AbstractService.send(AbstractService.java:301)
at com.chess.live.demo.DemoUserService.sendStatus(DemoUserService.java:238)
at com.chess.live.demo.DemoUserService.addUserToLists(DemoUserService.java:185)
at com.chess.live.demo.DemoUserService.login(DemoUserService.java:367)
at com.chess.live.ClientManager.login(ClientManager.java:361)
at com.chess.live.ChessClientBayeuxListener.clientAdded(ChessClientBayeuxListener.java:51)
at org.mortbay.cometd.AbstractBayeux.addClient(AbstractBayeux.java:512)
at org.mortbay.cometd.ClientImpl.(ClientImpl.java:74)
at org.mortbay.cometd.continuation.ContinuationClient.(ContinuationClient.java:43)
at org.mortbay.cometd.continuation.ContinuationBayeux.newRemoteClient(ContinuationBayeux.java:51)
at org.mortbay.cometd.AbstractBayeux$HandshakeHandler.handle(AbstractBayeux.java:1188)
at org.mortbay.cometd.AbstractBayeux.handle(AbstractBayeux.java:279)
at org.mortbay.cometd.continuation.ContinuationCometdServlet.service(ContinuationCometdServlet.java:108)
at org.mortbay.cometd.AbstractCometdServlet.service(AbstractCometdServlet.java:250)

The problem is that the constructor of ContinuationClient calls its super constructor, which is ClientImpl, which in turn calls the AbstractBayeux class, which invokes the clientAdded listeners - and if one of these listeners attempts to send a (in this case lazy) message, the _bayeux instance in the ContinuationClient is not yet set as we are still inside it's super constructor.

cometd-twisted: Long-polling transport doesn't keep connection

cometd-twisted does close connection for every request, no long-polling connection.

in ConnectedState.deliver:

            '''
            Only close the stream here if we've used it here.
            Otherwise leave it open. The HTTP buildResponse will make use of it.
            '''
            if self.ctypeProps["closeOnDelivery"]:
                GlobalLogger.info("Close stream on delivery")
                self.stream.finish()

comet_js_headers.py:

    "callback-polling": {
        # NOTE: the "callback-polling" method can be used via ScriptSrcIO for
        # x-domain polling
        "closeOnDelivery": True,
        "preamble":     "",
        # "envelope":       "cometd.deliver(%s);",
        "envelope":     "(%s)",
        "keepalive":    " ",
        "signoff":      "",
        "tunnelInit":   "",
        "contentType": "text/javascript"
    },

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.