RTC Forums
November 24, 2024, 12:44:59 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Login Register  
Pages: [1]
  Print  
Author Topic: Sending Multiple Messages from Client to Server with a Single Connection  (Read 4384 times)
DougB
Newbie
*
Posts: 19


« on: September 03, 2014, 06:08:55 PM »

In my application, I need to do the following:

- [HTTP Client] Send several messages from to the server over the *same* connection in bursts (e.g., there could be 10 calls to RtcDataRequest.Post() with different messages).
- [HTTP Server] Receive all of these messages before returning any data to the client, and return them out of order.

However, I've noticed on the server that if I don't return data for the first request, all of the other requests on the client will be held up until that happens.

The reason it's important is that the requests are coming into the client asynchronously in bursts, and the server may take different amounts of time to process each request.  Of course, I could use a separate connection for each request, but this defeats the purpose of reusing a single connection for performance purposes.

Is there a way to achieve this?

Thanks,
Doug
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #1 on: September 03, 2014, 07:38:03 PM »

HTTP is a request/response-based protocol, where each request from a Client has to be followed by a response from the Server, after which the Client can send the next request, the Server sends the response for that request, and so on. Even if you post several requests into the request queue on the Client side, the Client will never be sending more than one request to the Server at a time. After sending the first request to the Server, the Client will be waiting for a response from the Server. Only after receiving a complete response for the last request, then Client will check if there are more requests waiting in the request queue and then send the next request, following the same requst/response pattern.

The purpose of a connection pool is to reuse a connection which has been used before, but is currently NOT in use. In other words, you should return a connection back into the connection pool only AFTER the last request posted through that connection has been aborted, or a complete response was received. You will need to dinamically create new connections when there is no connection waiting in the pool, or implement a mechanism to wait for a connection to return to the pool if the number of connections already created is about to exceed your allowed limit.

Best Regards,
Danijel Tkalcec
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.024 seconds with 17 queries.