Absolute vs relative cometd path

47 views
Skip to first unread message

perissf

unread,
Jun 13, 2012, 1:13:04 PM6/13/12
to cometd...@googlegroups.com
I have just found out that in CometD 2.4.3 I need to specify the absolute path when connecting from Javascript / jQuery binding:
 
        var cometURL = "http://localhost:8080/MyApplicationContextRoot/cometd";
        cometd.configure({
            url: cometURL,
            logLevel: 'debug'
        });
This seems different from what I have done till now in CometD 2.3.1 from Javascript / Dojo binding:
 
        var cometURL = "/MyApplicationContextRoot/cometd";
Is this correct or am I doing something wrong?
 
Thanks
 

Simone Bordet

unread,
Jun 13, 2012, 3:52:09 PM6/13/12
to cometd...@googlegroups.com
Hi,
I'm surprised that worked.
Should be an absolute URL.

Simon
--
http://cometd.org
http://webtide.com
Developer advice, services and support
from the Jetty & CometD experts.
----
Finally, no matter how good the architecture and design are,
to deliver bug-free software with optimal performance and reliability,
the implementation technique must be flawless.   Victoria Livschitz

Harry Chesley

unread,
May 14, 2013, 12:25:32 PM5/14/13
to cometd...@googlegroups.com
I too am wondering about relative URLs. It is simpler to use a relative URL (just as you do for js and css subdirectories), and when I tried it recently, it seemed to work fine. Yet I've seen it said in a couple places (including this post) that you should only use absolute URLs. But I haven't been able to find anything that explains why absolute URLs are required.

Thanks.

Simone Bordet

unread,
May 14, 2013, 12:43:55 PM5/14/13
to cometd-users
Hi,

On Tue, May 14, 2013 at 6:25 PM, Harry Chesley <harry....@gmail.com> wrote:
> I too am wondering about relative URLs. It is simpler to use a relative URL
> (just as you do for js and css subdirectories), and when I tried it
> recently, it seemed to work fine. Yet I've seen it said in a couple places
> (including this post) that you should only use absolute URLs. But I haven't
> been able to find anything that explains why absolute URLs are required.

Because CometD mangles the URL for WebSocket, converting the protocol
from http:// to ws:// or https:// to wss://

As usual, patches are welcome :)

--
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.

Harry Chesley

unread,
May 14, 2013, 2:59:55 PM5/14/13
to cometd...@googlegroups.com
Aha. We force it to use long polling all the time -- our application
isn't sensitive to efficiency (relatively few users, light load), and
we're running on Tomcat, so we decided to avoid WebSocket compatibility
and testing issues. But that's something we should definitely be aware
of for the future.

As always, your answer is prompt and informative. CometD and us CometD
users are very lucky to have you responding to list postings. (Having
been on your side of things, I know you only hear from people when they
have issues, so wanted to take the opportunity to mention that.)

Simone Bordet

unread,
May 14, 2013, 3:07:46 PM5/14/13
to cometd-users
Hi,

On Tue, May 14, 2013 at 8:59 PM, Harry Chesley <che...@acm.org> wrote:
> Aha. We force it to use long polling all the time -- our application
> isn't sensitive to efficiency (relatively few users, light load), and
> we're running on Tomcat, so we decided to avoid WebSocket compatibility
> and testing issues. But that's something we should definitely be aware
> of for the future.
>
> As always, your answer is prompt and informative. CometD and us CometD
> users are very lucky to have you responding to list postings. (Having
> been on your side of things, I know you only hear from people when they
> have issues, so wanted to take the opportunity to mention that.)

Thanks!

May I ask why you run on Tomcat ? Just curious.

Harry Chesley

unread,
May 14, 2013, 3:14:14 PM5/14/13
to cometd...@googlegroups.com
Purely for logistical simplicity. Both our development environment
(Eclipse) and production environment (AWS Linux) comes with Tomcat built
in or easily installable. Jetty requires separate installation and/or
non-standard configuration. Plus we're familiar with Tomcat. As we have
limited manpower resources, anything that can be done turnkey, is.

In this particular case, Jetty would have bought us WebSockets, which is
not an essential feature, and not much else, and future versions are
expected to do WebSockets even with Tomcat. So since that was not an
essential feature, we opted for the simpler/known system.
Reply all
Reply to author
Forward
0 new messages