I encountered a weird problem. The same code runs on my local environment without any errors, but a time out error occurs when running on a test environment. I don’t know if anyone has encountered the same problem.
Just like the picture below, when I click the Batch Sync Product button, a method will be executed,
But there will be a time out error message, which makes me feel very confused
Unfortuantely you gave us no information about your code, but isn't it the same as in your previous thread, Extending RunBaseBatch Class to Create and Run a Batch?
If so, you seem to have a problem with a web service you're calling.
You might collect more information about your problem if you run your code in debugger.
/// <param name="sender"></param>
/// <param name="e"></param>
[FormControlEventHandler(formControlStr(EcoResProductDetailsExtended, BatchSyncProduct), FormControlEventType::Clicked)]
public static void BatchSyncProduct_OnClicked(FormControl sender, FormControlEventArgs e)
System.IO.Stream requestStream, responseStream;
System.IO.Stream requestStreams, responseStreams;
while select ItemId,Product,isSyncToCRM from InventTables where InventTables.isSyncToCRM !="Y"
httpHeaders = new System.Net.WebHeaderCollection();
clrObjs = System.Net.WebRequest::Create("This url is hidden");
requests = clrObjs;
requests.Method = "POST";
requests.ContentType = "application/x-www-form-urlencoded";
requestStreams = requests.GetRequestStream();
streamWriters = new System.IO.StreamWriter(requests.GetRequestStream());
responses = requests.GetResponse();
System.IO.StreamReader streamReads = new System.IO.StreamReader(responses.GetResponseStream());
container test =str2con(streamReads.ReadToEnd());
str test2= subStr(test1,10,2000);
str test3= strRem(test2,te1);
select firstonly RecId from EcoResProducts where EcoResProducts.RecId == InventTables.Product;;
select firstonly Description from EcoResProductTranslations where EcoResProductTranslations.Product == EcoResProducts.RecId;
select firstonly Price from INVENTTABLEMODULEs where INVENTTABLEMODULEs.ItemId== InventTables.ItemId&&INVENTTABLEMODULEs.ModuleType == 2;
select firstonly LeadTime,LowestQty from InventItemPurchSetups where InventItemPurchSetups.ItemId == InventTables.ItemId;
httpHeader = new System.Net.WebHeaderCollection();
clrObj = System.Net.WebRequest::Create("This url is hidden");
request = clrObj;
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
requestStream = request.GetRequestStream();
streamWriter = new System.IO.StreamWriter(request.GetRequestStream());
response = request.GetResponse();
System.IO.StreamReader streamRead = new System.IO.StreamReader(response.GetResponseStream());
select forUpdate InventTabless
where InventTabless.ItemId == InventTables.ItemId;
InventTabless.isSyncToCRM = "Y";
ex = CLRInterop::getLastException().GetBaseException();
This is my code. The difference is that it is not run through the RunBaseBatch class this time, but runs directly when I click the button, but this piece of code runs in my local environment without any problems, but this piece of code is under test There will be a timeout error when running on the environment
All right, so we're you two threads about the same error in the same code. Let's discuss the timeout error here and abandon the discussion in the other thread.
First of all, you need to find out where the error gets thrown. I guess it's caused by the web service being unresponsive.
Your own code isn't very efficient and it surely can be improved (for instance, you could fetch all data by a single query, while you're making several queries for every item), but I don't think it's the cause of the exception.
I have no way to debug my code in the test environment, how can I find out where the error is reported?
You can connect your DEV environment to the Test database and try your process again data from Test environment. See Debug a copy of the production database.
Also, didn't yopu say that you can reproduce the error in your DEV environment as well just by ruinning your code in batch?
I have used the test environment database in the local development environment, but the time out error cannot be reproduced
Then debugging the batch may be a good idea. It's likely both caused by the same problem.
Also, what about debugging the service called by your class? Does it get called at all? Is it responsive?
Sorry, I don’t quite understand the meaning of this sentence
The purpose of your code is calling a web service or something (via HttpRequest). All I know about it is what you told us, which is nothing, therefore I can't say anything more about it.
Anyway, you're calling something and you're getting a timeout exception, therefore it seems likely that this something doens't respond. Therefore you should check out what's going on - does it get called at all, or does something fail before even reaching the web service? Or does it get called but it gets stuck or too busy?
I just did a test. When I called this code, it was indeed running, and a timeout error occurred after 102 times of execution.