N
N
Nikolay2013-12-04 16:38:29
JavaScript
Nikolay, 2013-12-04 16:38:29

How to make a cross-domain Comet server?

The task arose to implement logn-polling requests to the comet server in a cross-domain way, and there seems to be nothing wrong with that, we set the necessary headers from our server and all cross-domain questions are removed. However, having chosen Dklab Realplexor as a comet server, I ran into the problem that an iframe is being created that immediately starts swearing at non-matching domains. Going to see the nearest, popular implementation of long-polling requests on VK, I found that these guys also use iframe. Unfortunately, I have not yet been able to understand why this iframe is needed at all, what is actually its essence. Is anyone in the know at all? Did you do something similar?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Andrey Unger, 2013-12-04
@Cobalt

What are you using as your JS client? Some libraries try to automatically determine which cross-domain bypass method can be used. And iframe is one of the "hacks" that can bypass cross-domain restrictions

A
Alexander Kouznetsov, 2013-12-05
@unconnected

The generic version is jsonp.
Iframe is an old hack that caused apple to sue google and win. Now it doesn't seem to work anywhere.

V
Viktor, 2014-10-05
@Levhav

I did a comet service and did without iframe, long-polling uses iframe as a very old hack for those cases where AJAX is not supported. So in VK it is clearly not for this, since they no longer support those browsers where it is needed.
In general, I recommend using websockets, it is already supported by many browsers ( caniuse.com/#search=websockets) and there are more opportunities and messages reach faster if there are a lot of them, in general, a lot of pluses.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question