V
V
Vyacheslav Belyaev2015-09-14 10:45:19
JavaScript
Vyacheslav Belyaev, 2015-09-14 10:45:19

How to organize long polling?

Hello. I'm trying to implement long polling for the crm system. We have <100 users and hosting (if it matters). On the test everything came out clearly (1 user), when transferred to the public part, everything started to hang wildly.

My assumption is this: when the page is loaded, a request is made to the server, which is spinning there for some time, when the page is updated, the second request and the third, etc., and all this from one user, from one tab, and there can be several tabs. And so one user can create a bunch of requests at the same time.
There are, of course, other methods for implementing this task, but I would like to bring this one to mind.

How can you cut off irrelevant requests that are spinning in a cycle on the server?

I got an idea. On the client side, generate a number for each tab (I just don't know how to save the number when refreshing the page). and with a request to send this number. Generate a server number to the klin number and cut off all other cycles with other server numbers but the same klin numbers. Question: how to implement the code transfer to the updated tab?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
lyeskin, 2015-09-14
@lyeskin

And what did web sockets not please in your case?

A
Alexander Khirenko, 2015-09-14
@Satanpit

Usually such requests are cut off by a timeout.
Those. you just need to make a limit for the request for about 60 seconds. and send some error to the client, and then bind it and make a reconnect.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question