Deprecated: Assigning the return value of new by reference is deprecated in /home/code4b/public_html/sysrc/wp-settings.php on line 472

Deprecated: Assigning the return value of new by reference is deprecated in /home/code4b/public_html/sysrc/wp-settings.php on line 487

Deprecated: Assigning the return value of new by reference is deprecated in /home/code4b/public_html/sysrc/wp-settings.php on line 494

Deprecated: Assigning the return value of new by reference is deprecated in /home/code4b/public_html/sysrc/wp-settings.php on line 530

Strict Standards: Declaration of Walker_Page::start_lvl() should be compatible with Walker::start_lvl(&$output) in /home/code4b/public_html/sysrc/wp-includes/classes.php on line 594

Strict Standards: Declaration of Walker_Page::end_lvl() should be compatible with Walker::end_lvl(&$output) in /home/code4b/public_html/sysrc/wp-includes/classes.php on line 594

Strict Standards: Declaration of Walker_Page::start_el() should be compatible with Walker::start_el(&$output) in /home/code4b/public_html/sysrc/wp-includes/classes.php on line 594

Strict Standards: Declaration of Walker_Page::end_el() should be compatible with Walker::end_el(&$output) in /home/code4b/public_html/sysrc/wp-includes/classes.php on line 594

Strict Standards: Declaration of Walker_PageDropdown::start_el() should be compatible with Walker::start_el(&$output) in /home/code4b/public_html/sysrc/wp-includes/classes.php on line 611

Strict Standards: Declaration of Walker_Category::start_lvl() should be compatible with Walker::start_lvl(&$output) in /home/code4b/public_html/sysrc/wp-includes/classes.php on line 705

Strict Standards: Declaration of Walker_Category::end_lvl() should be compatible with Walker::end_lvl(&$output) in /home/code4b/public_html/sysrc/wp-includes/classes.php on line 705

Strict Standards: Declaration of Walker_Category::start_el() should be compatible with Walker::start_el(&$output) in /home/code4b/public_html/sysrc/wp-includes/classes.php on line 705

Strict Standards: Declaration of Walker_Category::end_el() should be compatible with Walker::end_el(&$output) in /home/code4b/public_html/sysrc/wp-includes/classes.php on line 705

Strict Standards: Declaration of Walker_CategoryDropdown::start_el() should be compatible with Walker::start_el(&$output) in /home/code4b/public_html/sysrc/wp-includes/classes.php on line 728

Strict Standards: Redefining already defined constructor for class wpdb in /home/code4b/public_html/sysrc/wp-includes/wp-db.php on line 306

Deprecated: Assigning the return value of new by reference is deprecated in /home/code4b/public_html/sysrc/wp-includes/cache.php on line 103

Strict Standards: Redefining already defined constructor for class WP_Object_Cache in /home/code4b/public_html/sysrc/wp-includes/cache.php on line 425

Deprecated: Assigning the return value of new by reference is deprecated in /home/code4b/public_html/sysrc/wp-includes/query.php on line 21

Deprecated: Assigning the return value of new by reference is deprecated in /home/code4b/public_html/sysrc/wp-includes/theme.php on line 623

Strict Standards: Redefining already defined constructor for class WP_Dependencies in /home/code4b/public_html/sysrc/wp-includes/class.wp-dependencies.php on line 15
WebRequest and Unable to read data from the transport connection Error | Sysrc’s tech blog

WebRequest and Unable to read data from the transport connection Error

Tuesday, June 30th, 2009 | Code

Weird thing just happened, a Windows Service responsible for grabbing some data form an online XML source, suddenly stopped working after two years of continuous functioning…

First I thought that the remote XML had changed somehow but the service returned
“Unable to read data from the transport connection: The connection was closed.”

The code that connected to the remote XML was pretty low-tech:

WebRequest wRq = WebRequest.Create(remoteUri);
WebResponse wRs = wRq.GetResponse();
Stream strm = wRs.GetResponseStream();
StreamReader sr = new StreamReader(strm, Encoding.UTF7);
XmlDocument xDoc = new XmlDocument();
xDoc.Load(strm);
//IT WAS CRASHING HERE

After some research it seems that the remote side closes the connection prior to it being finished…
I had to change the code as follows and the problem was solved:


CookieContainer CC = new CookieContainer();
HttpWebRequest wRq = (HttpWebRequest)WebRequest.Create(remoteUri);
wRq.Proxy = null;
wRq.UseDefaultCredentials = true;
wRq.KeepAlive = false; //THIS DOES THE TRICK
wRq.ProtocolVersion = HttpVersion.Version10; // THIS DOES THE TRICK
wRq.CookieContainer = CC;
WebResponse wRs = wRq.GetResponse();
Stream strm = wRs.GetResponseStream();
StreamReader sr = new StreamReader(strm, Encoding.UTF7);
XmlDocument xDoc = new XmlDocument();
xDoc.Load(strm);
//NO LONGER CRASHING HERE

Archive


    Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/code4b/public_html/sysrc/wp-includes/kses.php on line 947

    Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/code4b/public_html/sysrc/wp-includes/kses.php on line 948
  • September 2009

  • Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/code4b/public_html/sysrc/wp-includes/kses.php on line 947

    Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/code4b/public_html/sysrc/wp-includes/kses.php on line 948
  • August 2009

  • Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/code4b/public_html/sysrc/wp-includes/kses.php on line 947

    Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/code4b/public_html/sysrc/wp-includes/kses.php on line 948
  • July 2009

  • Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/code4b/public_html/sysrc/wp-includes/kses.php on line 947

    Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/code4b/public_html/sysrc/wp-includes/kses.php on line 948
  • June 2009

  • Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/code4b/public_html/sysrc/wp-includes/kses.php on line 947

    Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/code4b/public_html/sysrc/wp-includes/kses.php on line 948
  • January 2009

  • Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/code4b/public_html/sysrc/wp-includes/kses.php on line 947

    Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/code4b/public_html/sysrc/wp-includes/kses.php on line 948
  • October 2008

  • Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/code4b/public_html/sysrc/wp-includes/kses.php on line 947

    Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/code4b/public_html/sysrc/wp-includes/kses.php on line 948
  • September 2008

Links


    Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/code4b/public_html/sysrc/wp-includes/kses.php on line 947

    Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/code4b/public_html/sysrc/wp-includes/kses.php on line 948

    Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/code4b/public_html/sysrc/wp-includes/kses.php on line 947

    Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/code4b/public_html/sysrc/wp-includes/kses.php on line 948
  • Iluminis
  • Synaptic Solutions

Meta

Search