Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Sat Oct 19, 2019 10:49 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Problem rapidly firing off asynchronous HTTPsocket POSTs
PostPosted: Tue Nov 13, 2012 11:27 am 
Offline

Joined: Wed Sep 22, 2010 3:40 pm
Posts: 4
I am a newbie at network communications so please forgive me if this question is incorrectly or imprecisely worded.

The problem space is remote control using M2M cloud based services. I have an application with a slider that is controlling a remote device. The cloud interface requires HTTP POSTs with the value of the slider (e.g. #00 - #FF representing hex number - 256 values).

I have a application where the Action method for the slider fills in a form and executes the HTTPsocket.post method. Works great as long as frequency at which the posts are made is very slow (e.g. once/second). However if I enable the slider's LiveScroll and send multiple posts quickly in a row then only the last one is registered by the cloud server.

I fired up Wireshark and noticed although there is a whole lot of TCP traffic between my machine and the server (proportional to how many times the Action method is being called), only one actual HTTP POST gets through (the final value).

Changing the post to be synchronous with a 1 second timeout works much better but then the performance is terrible. The cloud provider claims to be able to accept a large number of POSTS per second for each connection but unfortunately I don't understand enough about networking to identify where the bottleneck is.

Is the HTTPsocket object somehow collapsing the POSTS? Is there a way to successfully make a rapid transmission of asynchronous POSTs? Or am I missing some fundamental understanding of the protocol?


Top
 Profile  
Reply with quote  
 Post subject: Re: Problem rapidly firing off asynchronous HTTPsocket POSTs
PostPosted: Tue Nov 13, 2012 3:46 pm 
Offline
Real Software Engineer

Joined: Tue Jul 14, 2009 4:33 pm
Posts: 146
Location: Raleigh, NC
It's likely that it is the server that is "collapsing" the posts.

Keep in mind that with latency, each request could have a 200ms delay anyway when sending to a cloud based service.

Additionally, if you're using the same object over and over, it could be that the older objects are just going out of scope and not completing the transfer.

_________________
Greg O'Lone
Software Engineer
Real Software


Top
 Profile  
Reply with quote  
 Post subject: Re: Problem rapidly firing off asynchronous HTTPsocket POSTs
PostPosted: Tue Nov 13, 2012 4:18 pm 
Offline
User avatar

Joined: Mon Apr 02, 2007 2:08 am
Posts: 1225
Location: San Francisco, CA, USA
Stretch wrote:
Additionally, if you're using the same object over and over, it could be that the older objects are just going out of scope and not completing the transfer.

RB TCPsockets (of which the HTTPSocket is a subclass) don't destruct when going out of scope if they are currently connected.

_________________
Boredom Software


Top
 Profile  
Reply with quote  
 Post subject: Re: Problem rapidly firing off asynchronous HTTPsocket POSTs
PostPosted: Tue Nov 13, 2012 6:57 pm 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
If you're reusing the socket, it is very likely that you are interrupting the post yourself with each subsequent post. That would be consistent with only the last post succeeding. Check that the socket is done before you send the next post. Or use a separate socket for each post.


Top
 Profile  
Reply with quote  
 Post subject: Re: Problem rapidly firing off asynchronous HTTPsocket POSTs
PostPosted: Mon Dec 03, 2012 6:35 am 
Offline
User avatar

Joined: Fri Oct 28, 2005 7:05 am
Posts: 565
Location: Emsworth, UK
danjuliodesigns wrote:
I fired up Wireshark and noticed although there is a whole lot of TCP traffic between my machine and the server (proportional to how many times the Action method is being called), only one actual HTTP POST gets through (the final value).
You should be able to read the POST in the data segment of the packets you send to the server. Count up the number of times POST occurs in the outgoing packets and that's how many times your application sent an update request.

Quote:
Is the HTTPsocket object somehow collapsing the POSTS? Is there a way to successfully make a rapid transmission of asynchronous POSTs? Or am I missing some fundamental understanding of the protocol?

HTTP is transactional. For every POST sent to the server you should Get a status code, like 200 OK, back from the server. As far as I can tell from the LR, the receiving the status code corresponds to the PageReceived event firing. If you are sending out a new POST before the status code for the preceding one has been received (PageReceived fired), you are into pipe-lining territory. I would not (personally) trust RS' HTTPSocket to handle pipe-lining correctly.

If you only need to update the slider constantly for appearance purposes, it would be better to cache changes on the client and POST only the final value the user settles on. For instance, on the first change to the slider value set a timer to fire after (about) 250ms, reset it each time the value changes and make the POST when the timer fires.

_________________
Yes it's me in the avatar


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group