Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Dec 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    AJAX Long Polling, I can't do asynchronous requests sumultaneously

    I understand that many browsers have limitations (such as 6 requests per "group" meaning I guess how many tabs you have for lets say 'google.com')

    Now, I only have 1 constant request..

    It starts, and has a timeout of 60 seconds, I then start a separate request to "send" a message to the server, which will impact what is "returned" by the server on the longpoll connection..

    My current model, or design, albiet fully functional, has 1 major flaw..

    A request is made to the server, which islong polled, (E.G. thrown into a loop)

    The Long Poll will continue to long poll until one of the following two conditions are satisfied..

    1) The time() is > initial_time+60seconds
    2) There is data to be displayed, and found..

    the above works just fine.. However, while this is running, if I try to send a Message to the server, javascript wants to wait until the previous request has finished, before sending another request.. which sometimes could take a full minute to showup.. Hardly real time, which defeats the purpose of long polling?

    I figure maybe you can't have two connections running at the same exact time in Google Chrome, so I stop the current long poll

    - XMLHttpRequest.abort() -

    But that still, takes until the request (the server side code) ends processing and still takes up to 60 seconds until the message is sent to the server (which seems to be because it is processing till a specific time)...

    this is extremely frustrating..

    is there any way to fix this problem?

    Thank you all very much!

  • #2
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,470
    Thanks
    0
    Thanked 634 Times in 624 Posts
    You should be able to have up to 8 simultaneous http requests in modern browsers and up to 2 in antiquated browsers. If it is only allowing 1 then either you are doing a synchronous call or you are trying to reuse the same object for the call instead of creating a separate object for each call. You can only reuse an object if it has either returned a result or you call abort().
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #3
    New to the CF scene
    Join Date
    Dec 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I've figured it out a while ago, sorry for wasting your time bro, I wasn't lifting the session lock on the session files, so the subsequent requests needed to wait to secure a lock on the session files.. thats why it wasn't working..

    Thank you for your thought and answer, I completely appreciate it

    Russell

  • #4
    New to the CF scene
    Join Date
    Jul 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile

    Please tell how exactly you manage the session lock?

    For expample my client send AJAX request to ajax.php. Where should we put session_write_close? If not, what should we do?

    Thank you in advance.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •