How to send EOL characters in JSON string in comet response

80 views
Skip to first unread message

Gaurav Rastogi

unread,
Jan 30, 2014, 4:24:47 AM1/30/14
to cometd...@googlegroups.com
Hi All,

I was using Comet 1.0 and while doing handshake in response and End Of Line (EOL) which is "0D 0A" is been sent by Comet Server.
But when I upgrades Comet at server side to 2.7 then in handshake reponse this End Of Line (EOL) character is not present.
At client end this EOL characters are expected in order to parse the string correctly, but due to this missing EOL characters parsing at client side is failed for Handshake response.
Due to this the client which was working with Comet 1.0 has stopped working with Comet 2.7.

Please suggest workarounds or option to enable Comet 2.7 sending EOL characters.

Let me know in case more inputs are required.

Regards
Gaurav

Simone Bordet

unread,
Jan 30, 2014, 4:50:30 AM1/30/14
to cometd-users
Hi,
What client are we talking about here ?
CometD clients will handle this difference just fine.

--
Simone Bordet
----
http://cometd.org
http://webtide.com
http://intalio.com
Developer advice, training, services and support
from the Jetty & CometD experts.
Intalio, the modern way to build business applications.

Gaurav Rastogi

unread,
Jan 30, 2014, 9:12:11 AM1/30/14
to cometd...@googlegroups.com
Its not a cometD client.
It's a customized client which uses CometD API's and has its own parsing logic.
Here we are interested in knowing how to send EOL characters i.e. "0D 0A" with comet 2.7 as comet 1.0 was already sending these.

Simone Bordet

unread,
Jan 30, 2014, 9:35:28 AM1/30/14
to cometd-users
Hi,

On Thu, Jan 30, 2014 at 3:12 PM, Gaurav Rastogi
<gaurav....@gmail.com> wrote:
> Its not a cometD client.
> It's a customized client which uses CometD API's and has its own parsing
> logic.
> Here we are interested in knowing how to send EOL characters i.e. "0D 0A"
> with comet 2.7 as comet 1.0 was already sending these.

Sending EOL in CometD 1 was a mistake that we fixed in 2.x.
You should update your custom client, which should have not relied on
that in the first place.
The best way to read the Bayeux message is to look at the HTTP
Content-Length header.

Gaurav Rastogi

unread,
Jan 31, 2014, 4:32:35 AM1/31/14
to cometd...@googlegroups.com
Thanks for the reply.
Still Could you tell us any workaround which we can do to enable EOL characters from CometD as we don't want to change client deployments as it has huge business impact.
Shall be waiting for your response.

Gaurav Rastogi

unread,
Jan 31, 2014, 6:06:39 AM1/31/14
to cometd...@googlegroups.com
Also could you let us know the source code file name where we can change and append this EOL characters for JSON responses.
We need to try this with a patch as we need backward compatibly with clients for sure..


On Thursday, January 30, 2014 2:54:47 PM UTC+5:30, Gaurav Rastogi wrote:

Simone Bordet

unread,
Feb 3, 2014, 6:01:11 AM2/3/14
to cometd-users
Hi,

On Fri, Jan 31, 2014 at 12:06 PM, Gaurav Rastogi
<gaurav....@gmail.com> wrote:
> Also could you let us know the source code file name where we can change and
> append this EOL characters for JSON responses.
> We need to try this with a patch as we need backward compatibly with clients
> for sure..

You need to override JSONTransport.finishWrite(...) and add the
newline there, see
https://github.com/cometd/cometd/blob/2.8.x/cometd-java/cometd-java-server/src/main/java/org/cometd/server/transport/JSONTransport.java#L96.
Reply all
Reply to author
Forward
0 new messages