Having issues with long-polling in chrome

1,057 views
Skip to first unread message

neeraj kumar

unread,
Aug 9, 2011, 4:05:22 AM8/9/11
to cometd...@googlegroups.com
Hi,

I am not sure if this issue has already been reported/resolved.

In chrome, I get the warning:

Resource interpreted as Script but transferred with MIME type text/plain.

and calling subscribe/publish from within the browser do not work.

Has someone already faced a similar issue, or has an idea what should be changed on the server side so as to resolve this issue.

Just FYI, Im using jquery 1.5 with the cometd2.0 implementation.

Thanks
--
Neeraj

Simone Bordet

unread,
Aug 9, 2011, 4:48:13 AM8/9/11
to cometd...@googlegroups.com
Hi,

You need to be a lot more precise on what Chrome version, exact CometD
version, server configuration, etc.
Like this we can't help.

I just tried the reload demo on master and Chromium 13 works for me.

Please try the reload demo (that does not use websocket) first, and
see if it works for you.

Simon
--
http://bordet.blogspot.com
---
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

neeraj kumar

unread,
Aug 9, 2011, 10:01:59 AM8/9/11
to cometd...@googlegroups.com
Hi Simone,

I am sorry I forgot to specify a few things.

I guess , the issue is arising, because chrome tries to use websockets, and I have edited the code for cometd to use NTLM authentication, but have not supported the same for websocket connections to the jetty server.
Is there a way I can completely disable websocket support??

I guess that would solve my problem

Thanks
--
Neeraj


--
You received this message because you are subscribed to the Google Groups "cometd-users" group.
To post to this group, send email to cometd...@googlegroups.com
To unsubscribe from this group, send email to cometd-users...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cometd-users

Visit the CometD website at http://www.cometd.org

Simone Bordet

unread,
Aug 9, 2011, 10:59:03 AM8/9/11
to cometd...@googlegroups.com
Hi,

On Tue, Aug 9, 2011 at 16:01, neeraj kumar <neeraj...@gmail.com> wrote:
> Hi Simone,
> I am sorry I forgot to specify a few things.
> I guess , the issue is arising, because chrome tries to use websockets, and
> I have edited the code for cometd to use NTLM authentication, but have not
> supported the same for websocket connections to the jetty server.
> Is there a way I can completely disable websocket support??
> I guess that would solve my problem

It is disabled by default since 2.3.0.
What version are you using ?

neeraj kumar

unread,
Aug 9, 2011, 11:02:31 AM8/9/11
to cometd...@googlegroups.com
Im using 2.0.0 
and upgrading it would be an issue, as a few under the hood changes are done, implementing authentication.




Simone Bordet

unread,
Aug 9, 2011, 11:05:56 AM8/9/11
to cometd...@googlegroups.com
Hi,

On Tue, Aug 9, 2011 at 17:02, neeraj kumar <neeraj...@gmail.com> wrote:
> Im using 2.0.0
> and upgrading it would be an issue, as a few under the hood changes are
> done, implementing authentication.

To disable websocket on the client, do this, before calling
cometd.configure() or cometd.init():

cometd.unregisterTransport('websocket');

Let us know if it worked.

neeraj kumar

unread,
Aug 9, 2011, 11:06:59 AM8/9/11
to cometd...@googlegroups.com
Alternatively, is there a way I can specify "withCredentials" options for websockets (or something similar) , like I can for xhr objects in javascript??
That , might give me the goodness of websockets with the strength of authentication.

Simone Bordet

unread,
Aug 9, 2011, 11:12:40 AM8/9/11
to cometd...@googlegroups.com
Hi,

On Tue, Aug 9, 2011 at 17:06, neeraj kumar <neeraj...@gmail.com> wrote:
> Alternatively, is there a way I can specify "withCredentials" options for
> websockets (or something similar) , like I can for xhr objects in
> javascript??

I do not think the API allows that, and I do think it will ever allow that.

> That , might give me the goodness of websockets with the strength of
> authentication.

What "goodness" are you talking about ?

;)

neeraj kumar

unread,
Aug 9, 2011, 11:19:38 AM8/9/11
to cometd...@googlegroups.com

On Tue, Aug 9, 2011 at 8:42 PM, Simone Bordet <sbo...@intalio.com> wrote:
Hi,

On Tue, Aug 9, 2011 at 17:06, neeraj kumar <neeraj...@gmail.com> wrote:
> Alternatively, is there a way I can specify "withCredentials" options for
> websockets (or something similar) , like I can for xhr objects in
> javascript??

I do not think the API allows that, and I do think it will ever allow that.

> That , might give me the goodness of websockets with the strength of
> authentication.

What "goodness" are you talking about ?
Compared to longpolling, one single persistent connection with websockets looks really cool on firebug/chrome debugger.. ;)
 

;)

Simon
--
http://bordet.blogspot.com
---
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

neeraj kumar

unread,
Aug 9, 2011, 3:05:20 PM8/9/11
to cometd...@googlegroups.com
Hi , 


It completely skipped my mind to mention that this is happening cross-origin.
a recent post made me snap back to the fact.

Thanks
--
Neeraj

Simone Bordet

unread,
Aug 9, 2011, 4:24:10 PM8/9/11
to cometd...@googlegroups.com
Hi,

On Tue, Aug 9, 2011 at 21:05, neeraj kumar <neeraj...@gmail.com> wrote:
> Hi ,
>
> It completely skipped my mind to mention that this is happening
> cross-origin.
> a recent post made me snap back to the fact.

So, you disabled websocket ?

neeraj kumar

unread,
Aug 10, 2011, 12:39:11 AM8/10/11
to cometd...@googlegroups.com
Yes I disabled websockets,
But i still get the same error as mentioned in the very first mail...


neeraj kumar

unread,
Aug 10, 2011, 3:24:43 AM8/10/11
to cometd...@googlegroups.com
Hello,

Ok, after a few tweaks and additional filters, the error seems to have changed:

I added a filter to all the request (1.cross-origin --this was already there-- and 2.custom filter to change mime-type)
I return the MIME-type as "application/x-javascript" now.

Now , instead of getting the error  --Resource interpreted as Script but transferred as MIMETYPE text--,

I started getting the error:
-- XMLHTTPRequest cannot load http://mycrossdomain.com Origin http://mydomain.com is not allowed by Access-Control-Allow-Origin. --

The details of my cross origin filter are as follows:

 <!-- Cross origin filter -->
     <filter>
        <filter-name>cross-origin</filter-name>
        <filter-class>org.eclipse.jetty.servlets.CrossOriginFilter</filter-class>
        <init-param>
            <param-name>allowCredentials</param-name>
            <param-value>true</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>cross-origin</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

Any idea , why should the error occur , though im using a cross-origin filter??

Thanks
--
Neeraj

Simone Bordet

unread,
Aug 10, 2011, 4:15:46 AM8/10/11
to cometd...@googlegroups.com
Hi,

On Wed, Aug 10, 2011 at 09:24, neeraj kumar <neeraj...@gmail.com> wrote:
> Hello,
> Ok, after a few tweaks and additional filters, the error seems to have
> changed:
> I added a filter to all the request (1.cross-origin --this was already
> there-- and 2.custom filter to change mime-type)

You should not change the mime-type of the response... why are you doing this ?

> I return the MIME-type as "application/x-javascript" now.
> Now , instead of getting the error  --Resource interpreted as Script but
> transferred as MIMETYPE text--,
> I started getting the error:
> -- XMLHTTPRequest cannot load http://mycrossdomain.com Origin
> http://mydomain.com is not allowed by Access-Control-Allow-Origin. --

Perhaps you have headers in the request that are not allowed for CORS requests.

Need the dump of the request/responses, and exact version of browser
you're using.

Reply all
Reply to author
Forward
0 new messages