473,397 Members | 1,985 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

regarding REST call from .net client application

Hi

This is surya. . Im doing a .net client application to make a REST Call to netsuite and POST the Data from netsuite.

The Restlet(Netsuite) will run for 5 mins(max possible time).And Coming to my problem, whenever i trigger the Restlet(netsuite) from C# .NET Application,the restlet is called and it will start its execution process.But the connection which the C# .NET Client application has established with the RESTlet is getting closed exactly after 2mins without giving any response.And the response will be given once the RESTlet is finished.But the problem is m getting the error "The underlying Connection was Closed.The Connection was closed Unexpectedly" .And at the backend the RESTlet will run for 5mins as it will run for 5mins.And i have tried all the possible ways to increase the connection TimeLimit,including keepAlive,protocolversion,etc.. Can anyone come up with a clear solution of how to solve this

Here is my Code:


Expand|Select|Wrap|Line Numbers
  1. Dictionary<string, string> NS_SS_fmt = new Dictionary<string, string>();
  2.                     myWebRequest = (HttpWebRequest)WebRequest.Create(this.rest_url);
  3.                     myWebRequest.ContentType = "application/json";
  4.                     myWebRequest.Method = "POST";
  5.                     myWebRequest.Timeout = 1200000; //20mins
  6.                     myWebRequest.Credentials = CredentialCache.DefaultCredentials;
  7.                     //myWebRequest.Proxy = new WebProxy("127.0.0.1", 8888);
  8.                     //myWebRequest.ServicePoint.ConnectionLeaseTimeout = 300000;
  9.                     //myWebRequest.KeepAlive = true;
  10.                     //myWebRequest.ServicePoint.MaxIdleTime = 300000;
  11.                     //myWebRequest.PreAuthenticate = true;
  12.                     //myWebRequest.ProtocolVersion = HttpVersion.Version11;
  13.                     //myWebRequest.AllowAutoRedirect = true;
  14.                     //myWebRequest.MaximumAutomaticRedirections = 10;
  15.                     //myWebRequest.ReadWriteTimeout = 500000;
  16.                     this.setHeader();
  17.                     NS_SS_fmt.Add("requestType", rec_type);
  18.  
  19.                     this.sendHttpRequest(NS_SS_fmt);
  20.  
  21.                     string response = this._getHttpResponse();
  22.  
  23. public void setHeader()
  24.         {
  25.  
  26.             // Nothing But Authentication Header
  27.             myWebRequest.Headers.Add("User-Agent-x:SuiteScript-Call");
  28.             myWebRequest.Headers.Add("Authorization:NLAuth nlauth_account="+this.netsuite_acc_name+",nlauth_email="+this.netsuite_email+",nlauth_signature="+this.netsuite_pwd+",nlauth_role="+this.netsuite_role);
  29.             logger.Info("Netsuite Header Credential Done");
  30.  
  31.         }public void sendHttpRequest(Dictionary<string, string> requestPair) // to netsuite Rest 
  32.         {
  33.             try
  34.             {
  35.                 var json_object = new JavaScriptSerializer().Serialize(requestPair);
  36.                 using (var streamWriter = new StreamWriter(myWebRequest.GetRequestStream())) { streamWriter.Write(json_object); }
  37.             }
  38.             catch (Exception e)
  39.             {
  40.                 System.Environment.Exit(2);
  41.  
  42.             }
  43.         }
  44. string response = (HttpWebResponse)myWebRequest.GetResponse();//My connection will get closed at this place while getting the response
Mar 21 '14 #1
0 1343

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Pat L. | last post by:
I want to launch a client application from the server and send it some parameters. The application is written in PowerBuilder. Any ideas on how to do this? Pat
1
by: Job Lot | last post by:
Could someone provide some help or tips on creating “Registration Key” for client application? I am designing an application in VB.Net which will be distributed to our clients. I want my...
2
by: Raquel | last post by:
The following is a piece of code from my client application which is trying to call stored procedure SP1: String callstmt = "CALL DB2ADMIN.SP1(?,?,?)"; CallableStatement clst1 =...
0
by: Tim Pham via DotNetMonster.com | last post by:
Hi, I'm working on the project that use a printer driver (myPrinter) to call my application. Actually, I created another application and listen to that event. Now I don't how to use this service...
2
by: Dmitry Sazonov | last post by:
I'm novice here and I'm sorry for stupid question. We are trying to understand web services architecture, is it better than TIBCO.Randevouz and does webservices fit our needs. I understand, I...
5
by: Daniel | last post by:
will a client application using ado.net get an exception if the command is executing a stored procedure that does a RAISEERROR in its tsql?
22
by: Jordan S. | last post by:
SQL Server will be used as the back-end database to a non trivial client application. In question is the choice of client application: I need to be able to speak intelligently about when one...
6
by: Simon Harvey | last post by:
Hi everyone, We have a need to make a Windows Forms (2.0) client application that will be installed on our clients site. The data that the application uses needs to be centrally available to a...
1
by: Sparky74 | last post by:
Hi Everybody. I have been searching for many hours for an answer to this problem. I hope somebody can help me. I have a C# .NET client application that connects to a TCP/IP C++ server application...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.