Login Page - Create Account

Support Board


Date/Time: Mon, 06 May 2024 10:39:13 +0000



Problems with ACSIL HTTP Support

View Count: 1950

[2016-01-10 02:39:09]
managematics - Posts: 3
I am attempting to move one of my studies to Sierra Chart and it requires that I retrieve two different files from my server. However, I have found that when I attempt this, sc.HTTPResponse will often contain the contents of a previously fetched file. Here is a small test study that shows the problem:

#include "sierrachart.h"

SCDLLName("HTTP Test")

SCSFExport scsf_HTTPTest(SCStudyGraphRef sc)
{
    SCString URL1="http://www.fwtrader.com/voodoo/a.txt";
    SCString URL2="http://www.fwtrader.com/voodoo/b.txt";
    SCString msg;
    sc.FreeDLL = 1;
    sc.AutoLoop = 1;
    
  
  if (sc.Index == 0)
  {
    if(!sc.MakeHTTPRequest(URL1))
    {
      sc.AddMessageToLog("Error requesting file a",true);
    }
    else
    {
      msg.Format("response a: %s", sc.HTTPResponse.GetChars());
      sc.AddMessageToLog(msg, true);
    }
    
    if(!sc.MakeHTTPRequest(URL2))
    {
      sc.AddMessageToLog("Error requesting file b",true);
    }
    else
    {
      msg.Format("response b: %s", sc.HTTPResponse.GetChars());
      sc.AddMessageToLog(msg,true);
    }
        sc.HTTPResponse = "";
  }
}


And here is the section of the log file which shows the result:

US30 [C] 1 Min #2 | Reloading chart. | 2016-01-09 20:25:40
US30 [C] 5 Min #2 | No contract months found for symbol. Unable to build continuous futures contract chart. | 2016-01-09 20:25:40
US30 [C] 5 Min #2 | There are no continuous futures contract symbols. Loading data normally. | 2016-01-09 20:25:40
US30 [C] 5 Min #2 | Study: Custom DLL Study | Making HTTP request. | 2016-01-09 20:25:41
Chart: US30 [C] 5 Min #2 | Study: Custom DLL Study | response a: File B this is. | 2016-01-09 20:25:41 *
US30 [C] 5 Min #2 | Study: Custom DLL Study | Making HTTP request. | 2016-01-09 20:25:41
Chart: US30 [C] 5 Min #2 | Study: Custom DLL Study | response b: File B this is. | 2016-01-09 20:25:41 *
HTTP connection to www.fwtrader.com:80 (0) | Resolved address www.fwtrader.com to IP 74.208.30.141 | 2016-01-09 20:25:41
HTTP connection to www.fwtrader.com:80 (138) | Connected. | 2016-01-09 20:25:41
HTTP connection to www.fwtrader.com:80 (138) | Closed. No error. | 2016-01-09 20:25:43
HTTP connection to www.fwtrader.com:80 (138) | Shutdown and closed. | 2016-01-09 20:25:43


The files a.txt and b.txt each have a single line of content which identifies them. But you can see that although the study attempts to fetch two different files, after each sc.HTTPResponse only has the content of b.txt.

Can you provide any guidance?
Date Time Of Last Edit: 2016-01-10 02:40:30
[2016-01-10 02:52:03]
Sierra Chart Engineering - Posts: 104368
The study can only make one request at a time. Once the first one finishes do the next one.

If it is critical to make multiple requests at the same time, we could add support for that. However, not certain how quickly we can do it.
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
Date Time Of Last Edit: 2016-01-10 02:58:14
[2016-01-10 03:11:25]
managematics - Posts: 3
Can you please elaborate on "once the first one finishes do the next one"? Is sc.MakeHTTPRequest non-blocking? If so, is there some way to tell when it completes? This is information I only want to pull down once inside i.e when sc.Index==0. So what do I do until it completes? I have tried sleeping for a few seconds before checking HTTPResponse but it doesn't change the behavior.
[2016-01-10 04:38:28]
Sierra Chart Engineering - Posts: 104368
Refer to the documentation for this function here:
https://www.sierrachart.com/index.php?page=doc/doc_ACSIL_Members_Functions.html#scMakeHTTPRequest

We did some updates to the documentation. However, it is already quite clear how this function works from the example given.
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
[2016-01-10 23:18:51]
managematics - Posts: 3
OK, I have fully rebuilt my study as a state machine to deal with the non-blocking HTTP request. However, there are still issues when markets are closed.

What is occurring is that the HTTP Request is made and then most or all of the calls to the study to process historical bars occur while still waiting for a response to the first request. Any additional calls come while waiting for the second request. If markets are not open then there are no additional calls to keep the state machine moving.

This happened all day long today (Sunday) with things finally working as expected on futures charts after markets opened.

Anything I can do about this?
[2016-01-13 00:02:49]
Sierra Chart Engineering - Posts: 104368
We apologize for the delay. The study function is definitely going to be called when there is a response received. Is that what you are asking about? There should not be any problem with that whatsoever.

Another thing you may also want to use is Manual Looping:
http://www.sierrachart.com/index.php?page=doc/doc_ACS_ArraysAndLooping.html
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account