473,698 Members | 2,873 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Unable to write data to the transport connection

Hello,

I'm trying to upload a file programatically and occasionally I get the
following error message.

Unable to write data to the transport connection: An established connection
was aborted by the software in your host machine.

Stack Trace
at System.Net.Sock ets.NetworkStre am.Write(Byte[] buffer, Int32 offset, Int32
size)
at System.Net.FtpD ataStream.Write (Byte[] buffer, Int32 offset, Int32
size)
at HSMoveFiles.FTP Client.Upload(F ileInfo fi, String targetFilename) in
C:\DOTNET\HSMov eFiles\FTPClien t.cs:line 177

The source code for FTPClient.cs came from the following URL
http://www.codeproject.com/vb/net/FtpClient.asp

The exception is been thrown when trying to write the Stream.
rs.Write(conten t, 0, dataRead)

Has anyone got any Idea why this might happen and how to solve it?

Exception is caught at line number 185. Throw ex;.

Here is the source code. See line number 177.

using System.Collecti ons.Generic;

using System;

using System.Net;

using System.IO;

using System.Runtime. Remoting.Lifeti me;

using System.Text.Reg ularExpressions ;

namespace HSMoveFiles

{

#region "FTP client class"

/// <summary>

/// A wrapper class for .NET 2.0 FTP

/// </summary>

/// <remarks>

/// This class does not hold open an FTP connection but

/// instead is stateless: for each FTP request it

/// connects, performs the request and disconnects.

/// </remarks>

public class FTPClient

{

#region "CONSTRUCTO RS"

/// <summary>

/// Blank constructor

/// </summary>

/// <remarks>Hostna me, username and password must be set manually</remarks>

public FTPClient()

{

}

/// <summary>

/// Constructor just taking the hostname

/// </summary>

/// <param name="Hostname" >in either ftp://ftp.host.com or ftp.host.com
form</param>

/// <remarks></remarks>

public FTPClient(strin g Hostname)

{

_hostname = Hostname;

}

/// <summary>

/// Constructor taking hostname, username and password

/// </summary>

/// <param name="Hostname" >in either ftp://ftp.host.com or ftp.host.com
form</param>

/// <param name="Username" >Leave blank to use 'anonymous' but set password
to your email</param>

/// <param name="Password" ></param>

/// <remarks></remarks>

public FTPClient(strin g Hostname, string Username, string Password)

{

_hostname = Hostname;

_username = Username;

_password = Password;

}

#endregion

#region "Directory functions"

/// <summary>

/// Return a simple directory listing

/// </summary>

/// <param name="directory ">Directory to list, e.g. /pub</param>

/// <returns>A list of filenames and directories as a List(of
String)</returns>

/// <remarks>For a detailed directory listing, use
ListDirectoryDe tail</remarks>

public List<stringList Directory(strin g directory)

{

//return a simple list of filenames in directory

System.Net.FtpW ebRequest ftp = GetRequest(GetD irectory(direct ory));

//Set request to do simple list

ftp.Method = System.Net.WebR equestMethods.F tp.ListDirector y;

string str = GetStringRespon se(ftp);

//replace CRLF to CR, remove last instance

str = str.Replace("\r \n", "\r").TrimEnd(' \r');

//split the string into a list

List<stringresu lt = new List<string>();

result.AddRange (str.Split('\r' ));

return result;

}

/// <summary>

/// Return a detailed directory listing

/// </summary>

/// <param name="directory ">Directory to list, e.g. /pub/etc</param>

/// <returns>An FTPDirectory object</returns>

public FTPdirectory ListDirectoryDe tail(string directory)

{

System.Net.FtpW ebRequest ftp = GetRequest(GetD irectory(direct ory));

//Set request to do simple list

ftp.Method = System.Net.WebR equestMethods.F tp.ListDirector yDetails;

string str = GetStringRespon se(ftp);

//replace CRLF to CR, remove last instance

str = str.Replace("\r \n", "\r").TrimEnd(' \r');

//split the string into a list

return new FTPdirectory(st r, _lastDirectory) ;

}

#endregion

#region "Upload: File transfer TO ftp server"

/// <summary>

/// Copy a local file to the FTP server

/// </summary>

/// <param name="localFile name">Full path of the local file</param>

/// <param name="targetFil ename">Target filename, if required</param>

/// <returns></returns>

/// <remarks>If the target filename is blank, the source filename is used

/// (assumes current directory). Otherwise use a filename to specify a name

/// or a full path and filename if required.</remarks>

public bool Upload(string localFilename, string targetFilename)

{

//1. check source

if (!File.Exists(l ocalFilename))

{

throw (new ApplicationExce ption("File " + localFilename + " not found"));

}

//copy to FI

FileInfo fi = new FileInfo(localF ilename);

return Upload(fi, targetFilename) ;

}

/// <summary>

/// Upload a local file to the FTP server

/// </summary>

/// <param name="fi">Sourc e file</param>

/// <param name="targetFil ename">Target filename (optional)</param>

/// <returns></returns>

public bool Upload(FileInfo fi, string targetFilename)

{

//copy the file specified to target file: target file can be full path or
just filename (uses current dir)

//1. check target

string target;

if (targetFilename .Trim() == "")

{

//Blank target: use source filename & current dir

target = this.CurrentDir ectory + fi.Name;

}

else if (targetFilename .Contains("/"))

{

//If contains / treat as a full path

target = AdjustDir(targe tFilename);

}

else

{

//otherwise treat as filename only, use current directory

target = CurrentDirector y + targetFilename;

}

string URI = Hostname + target;

//perform copy

System.Net.FtpW ebRequest ftp = GetRequest(URI) ;

//Set request to upload a file in binary

ftp.Method = System.Net.WebR equestMethods.F tp.UploadFile;

ftp.UseBinary = true;

//Notify FTP of the expected size

ftp.ContentLeng th = fi.Length;

//create byte array to store: ensure at least 1 byte!

int BufferSize = 2048;

byte[] content = new byte[BufferSize - 1 + 1];

int dataRead;

//open file for reading

using (FileStream fs = fi.OpenRead())

{

try

{

//open request to send

using (Stream rs = ftp.GetRequestS tream())

{

do

{

dataRead = fs.Read(content , 0, BufferSize);

rs.Write(conten t, 0, dataRead);

} while (!(dataRead < BufferSize));

rs.Close();

}

}

catch (Exception ex)

{

throw ex;

}

finally

{

//ensure file closed

fs.Close();

ftp = null;

}

}

return true;

}

#endregion

#region "Download: File transfer FROM ftp server"

/// <summary>

/// Copy a file from FTP server to local

/// </summary>

/// <param name="sourceFil ename">Target filename, if required</param>

/// <param name="localFile name">Full path of the local file</param>

/// <returns></returns>

/// <remarks>Targ et can be blank (use same filename), or just a filename

/// (assumes current directory) or a full path and filename</remarks>

public bool Download(string sourceFilename, string localFilename, bool
PermitOverwrite )

{

//2. determine target file

FileInfo fi = new FileInfo(localF ilename);

return this.Download(s ourceFilename, fi, PermitOverwrite );

}

//Version taking an FtpFileInfo

public bool Download(FTPfil eInfo file, string localFilename, bool
PermitOverwrite )

{

return this.Download(f ile.FullName, localFilename, PermitOverwrite );

}

//Another version taking FtpFileInfo and FileInfo

public bool Download(FTPfil eInfo file, FileInfo localFI, bool
PermitOverwrite )

{

return this.Download(f ile.FullName, localFI, PermitOverwrite );

}

//Version taking string/FileInfo

public bool Download(string sourceFilename, FileInfo targetFI, bool
PermitOverwrite )

{

//1. check target

if (targetFI.Exist s && !(PermitOverwri te))

{

throw (new ApplicationExce ption("Target file already exists"));

}

//2. check source

string target;

if (sourceFilename .Trim() == "")

{

throw (new ApplicationExce ption("File not specified"));

}

else if (sourceFilename .Contains("/"))

{

//treat as a full path

target = AdjustDir(sourc eFilename);

}

else

{

//treat as filename only, use current directory

target = CurrentDirector y + sourceFilename;

}

string URI = Hostname + target;

//3. perform copy

System.Net.FtpW ebRequest ftp = GetRequest(URI) ;

//Set request to download a file in binary mode

ftp.Method = System.Net.WebR equestMethods.F tp.DownloadFile ;

ftp.UseBinary = true;

//open request and get response stream

using (FtpWebResponse response = (FtpWebResponse )ftp.GetRespons e())

{

using (Stream responseStream = response.GetRes ponseStream())

{

//loop to read & write to file

using (FileStream fs = targetFI.OpenWr ite())

{

try

{

byte[] buffer = new byte[2048];

int read = 0;

do

{

read = responseStream. Read(buffer, 0, buffer.Length);

fs.Write(buffer , 0, read);

} while (!(read == 0));

responseStream. Close();

fs.Flush();

fs.Close();

}

catch (Exception)

{

//catch error and delete file only partially downloaded

fs.Close();

//delete target file as it's incomplete

targetFI.Delete ();

throw;

}

}

responseStream. Close();

}

response.Close( );

}

return true;

}

#endregion

#region "Other functions: Delete rename etc."

/// <summary>

/// Delete remote file

/// </summary>

/// <param name="filename" >filename or full path</param>

/// <returns></returns>

/// <remarks></remarks>

public bool FtpDelete(strin g filename)

{

//Determine if file or full path

string URI = this.Hostname + GetFullPath(fil ename);

System.Net.FtpW ebRequest ftp = GetRequest(URI) ;

//Set request to delete

ftp.Method = System.Net.WebR equestMethods.F tp.DeleteFile;

try

{

//get response but ignore it

string str = GetStringRespon se(ftp);

}

catch (Exception)

{

return false;

}

return true;

}

/// <summary>

/// Determine if file exists on remote FTP site

/// </summary>

/// <param name="filename" >Filename (for current dir) or full path</param>

/// <returns></returns>

/// <remarks>Note this only works for files</remarks>

public bool FtpFileExists(s tring filename)

{

//Try to obtain filesize: if we get error msg containing "550"

//the file does not exist

try

{

long size = GetFileSize(fil ename);

return true;

}

catch (Exception ex)

{

//only handle expected not-found exception

if (ex is System.Net.WebE xception)

{

//file does not exist/no rights error = 550

if (ex.Message.Con tains("550"))

{

//clear

return false;

}

else

{

throw;

}

}

else

{

throw;

}

}

}

/// <summary>

/// Determine size of remote file

/// </summary>

/// <param name="filename" ></param>

/// <returns></returns>

/// <remarks>Thro ws an exception if file does not exist</remarks>

public long GetFileSize(str ing filename)

{

string path;

if (filename.Conta ins("/"))

{

path = AdjustDir(filen ame);

}

else

{

path = this.CurrentDir ectory + filename;

}

string URI = this.Hostname + path;

System.Net.FtpW ebRequest ftp = GetRequest(URI) ;

//Try to get info on file/dir?

ftp.Method = System.Net.WebR equestMethods.F tp.GetFileSize;

string tmp = this.GetStringR esponse(ftp);

return GetSize(ftp);

}

public bool FtpRename(strin g sourceFilename, string newName)

{

//Does file exist?

string source = GetFullPath(sou rceFilename);

if (!FtpFileExists (source))

{

throw (new FileNotFoundExc eption("File " + source + " not found"));

}

//build target name, ensure it does not exist

string target = GetFullPath(new Name);

if (target == source)

{

throw (new ApplicationExce ption("Source and target are the same"));

}

else if (FtpFileExists( target))

{

throw (new ApplicationExce ption("Target file " + target + " already
exists"));

}

//perform rename

string URI = this.Hostname + source;

System.Net.FtpW ebRequest ftp = GetRequest(URI) ;

//Set request to delete

ftp.Method = System.Net.WebR equestMethods.F tp.Rename;

ftp.RenameTo = target;

try

{

//get response but ignore it

string str = GetStringRespon se(ftp);

}

catch (Exception)

{

return false;

}

return true;

}

public bool FtpCreateDirect ory(string dirpath)

{

//perform create

string URI = this.Hostname + AdjustDir(dirpa th);

System.Net.FtpW ebRequest ftp = GetRequest(URI) ;

//Set request to MkDir

ftp.Method = System.Net.WebR equestMethods.F tp.MakeDirector y;

try

{

//get response but ignore it

string str = GetStringRespon se(ftp);

}

catch (Exception)

{

return false;

}

return true;

}

public bool FtpDeleteDirect ory(string dirpath)

{

//perform remove

string URI = this.Hostname + AdjustDir(dirpa th);

System.Net.FtpW ebRequest ftp = GetRequest(URI) ;

//Set request to RmDir

ftp.Method = System.Net.WebR equestMethods.F tp.RemoveDirect ory;

try

{

//get response but ignore it

string str = GetStringRespon se(ftp);

}

catch (Exception)

{

return false;

}

return true;

}

#endregion

#region "private supporting fns"

//Get the basic FtpWebRequest object with the

//common settings and security

private FtpWebRequest GetRequest(stri ng URI)

{

//create request

FtpWebRequest result = (FtpWebRequest) FtpWebRequest.C reate(URI);

//Set the login details

result.Credenti als = GetCredentials( );

//Do not keep alive (stateless mode)

result.KeepAliv e = true;

return result;

}

/// <summary>

/// Get the credentials from username/password

/// </summary>

private System.Net.ICre dentials GetCredentials( )

{

return new System.Net.Netw orkCredential(U sername, Password);

}

/// <summary>

/// returns a full path using CurrentDirector y for a relative file reference

/// </summary>

private string GetFullPath(str ing file)

{

if (file.Contains( "/"))

{

return AdjustDir(file) ;

}

else

{

return this.CurrentDir ectory + file;

}

}

/// <summary>

/// Amend an FTP path so that it always starts with /

/// </summary>

/// <param name="path">Pat h to adjust</param>

/// <returns></returns>

/// <remarks></remarks>

private string AdjustDir(strin g path)

{

return ((path.StartsWi th("/")) ? "" : "/").ToString () + path;

}

private string GetDirectory(st ring directory)

{
string URI;

if (directory == "")

{

//build from current

URI = Hostname + this.CurrentDir ectory;

_lastDirectory = this.CurrentDir ectory;

}

else

{

if (!directory.Sta rtsWith("/"))

{

throw (new ApplicationExce ption("Director y should start with /"));

}

URI = this.Hostname + directory;

_lastDirectory = directory;

}

return URI;

}

//stores last retrieved/set directory

private string _lastDirectory = "";

/// <summary>

/// Obtains a response stream as a string

/// </summary>

/// <param name="ftp">curr ent FTP request</param>

/// <returns>Stri ng containing response</returns>

/// <remarks>FTP servers typically return strings with CR and

/// not CRLF. Use respons.Replace (vbCR, vbCRLF) to convert

/// to an MSDOS string</remarks>

private string GetStringRespon se(FtpWebReques t ftp)

{

//Get the result, streaming to a string

string result = "";

using (FtpWebResponse response = (FtpWebResponse )ftp.GetRespons e())

{

long size = response.Conten tLength;

using (Stream datastream = response.GetRes ponseStream())

{

using (StreamReader sr = new StreamReader(da tastream))

{

result = sr.ReadToEnd();

sr.Close();

}

datastream.Clos e();

}

response.Close( );

}

return result;

}

/// <summary>

/// Gets the size of an FTP request

/// </summary>

/// <param name="ftp"></param>

/// <returns></returns>

/// <remarks></remarks>

private long GetSize(FtpWebR equest ftp)

{

long size;

using (FtpWebResponse response = (FtpWebResponse )ftp.GetRespons e())

{

size = response.Conten tLength;

response.Close( );

}

return size;

}

#endregion

#region "Properties "

private string _hostname;

/// <summary>

/// Hostname

/// </summary>

/// <value></value>

/// <remarks>Hostna me can be in either the full URL format

/// ftp://ftp.myhost.com or just ftp.myhost.com

/// </remarks>

public string Hostname

{

get

{

if (_hostname.Star tsWith("ftp://"))

{

return _hostname;

}

else

{

return "ftp://" + _hostname;

}

}

set

{

_hostname = value;

}

}

private string _username;

/// <summary>

/// Username property

/// </summary>

/// <value></value>

/// <remarks>Can be left blank, in which case 'anonymous' is
returned</remarks>

public string Username

{

get

{

return (_username == "" ? "anonymous" : _username);

}

set

{

_username = value;

}

}

private string _password;

public string Password

{

get

{

return _password;

}

set

{

_password = value;

}

}

/// <summary>

/// The CurrentDirector y value

/// </summary>

/// <remarks>Defaul ts to the root '/'</remarks>

private string _currentDirecto ry = "/";

public string CurrentDirector y

{

get

{

//return directory, ensure it ends with /

return _currentDirecto ry + ((_currentDirec tory.EndsWith("/")) ? "" :
"/").ToString ();

}

set

{

if (!value.StartsW ith("/"))

{

throw (new ApplicationExce ption("Director y should start with /"));

}

_currentDirecto ry = value;

}

}

#endregion

}

#endregion

#region "FTP file info class"

/// <summary>

/// Represents a file or directory entry from an FTP listing

/// </summary>

/// <remarks>

/// This class is used to parse the results from a detailed

/// directory list from FTP. It supports most formats of

/// </remarks>

public class FTPfileInfo

{

//Stores extended info about FTP file

#region "Properties "

public string FullName

{

get

{

return Path + Filename;

}

}

public string Filename

{

get

{

return _filename;

}

}

public string Path

{

get

{

return _path;

}

}

public DirectoryEntryT ypes FileType

{

get

{

return _fileType;

}

}

public long Size

{

get

{

return _size;

}

}

public DateTime FileDateTime

{

get

{

return _fileDateTime;

}

}

public string Permission

{

get

{

return _permission;

}

}

public string Extension

{

get

{

int i = this.Filename.L astIndexOf(".") ;

if (i >= 0 && i < (this.Filename. Length - 1))

{

return this.Filename.S ubstring(i + 1);

}

else

{

return "";

}

}

}

public string NameOnly

{

get

{

int i = this.Filename.L astIndexOf(".") ;

if (i 0)

{

return this.Filename.S ubstring(0, i);

}

else

{

return this.Filename;

}

}

}

private string _filename;

private string _path;

private DirectoryEntryT ypes _fileType;

private long _size;

private DateTime _fileDateTime;

private string _permission;

#endregion

/// <summary>

/// Identifies entry as either File or Directory

/// </summary>

public enum DirectoryEntryT ypes

{

File,

Directory

}

/// <summary>

/// Constructor taking a directory listing line and path

/// </summary>

/// <param name="line">The line returned from the detailed directory
list</param>

/// <param name="path">Pat h of the directory</param>

/// <remarks></remarks>

public FTPfileInfo(str ing line, string path)

{

//parse line

Match m = GetMatchingRege x(line);

if (m == null)

{

//failed

throw (new ApplicationExce ption("Unable to parse line: " + line));

}

else

{

_filename = m.Groups["name"].Value;

_path = path;

Int64.TryParse( m.Groups["size"].Value, out _size);

//_size = System.Convert. ToInt32(m.Group s["size"].Value);

_permission = m.Groups["permission "].Value;

string _dir = m.Groups["dir"].Value;

if (_dir != "" && _dir != "-")

{

_fileType = DirectoryEntryT ypes.Directory;

}

else

{

_fileType = DirectoryEntryT ypes.File;

}

try

{

_fileDateTime = DateTime.Parse( m.Groups["timestamp"].Value);

}

catch (Exception)

{

_fileDateTime = Convert.ToDateT ime(null);

}

}

}

private Match GetMatchingRege x(string line)

{

Regex rx;

Match m;

for (int i = 0; i <= _ParseFormats.L ength - 1; i++)

{

rx = new Regex(_ParseFor mats[i]);

m = rx.Match(line);

if (m.Success)

{

return m;

}

}

return null;

}

#region "Regular expressions for parsing LIST results"

/// <summary>

/// List of REGEX formats for different FTP server listing formats

/// </summary>

/// <remarks>

/// The first three are various UNIX/LINUX formats, fourth is for MS FTP

/// in detailed mode and the last for MS FTP in 'DOS' mode.

/// I wish VB.NET had support for Const arrays like C# but there you go

/// </remarks>

private static string[] _ParseFormats = new string[] {

"(?<dir>[\\-d])(?<permission> ([\\-r][\\-w][\\-xs]){3})\\s+\\d+\\ s+\\w+\\s+\\w+\ \s+(?<size>\\d+ )\\s+(?<timesta mp>\\w+\\s+\\d+ \\s+\\d{4})\\s+ (?<name>.+)",

"(?<dir>[\\-d])(?<permission> ([\\-r][\\-w][\\-xs]){3})\\s+\\d+\\ s+\\d+\\s+(?<si ze>\\d+)\\s+(?< timestamp>\\w+\ \s+\\d+\\s+\\d{ 4})\\s+(?<name> .+)",

"(?<dir>[\\-d])(?<permission> ([\\-r][\\-w][\\-xs]){3})\\s+\\d+\\ s+\\d+\\s+(?<si ze>\\d+)\\s+(?< timestamp>\\w+\ \s+\\d+\\s+\\d{ 1,2}:\\d{2})\\s +(?<name>.+)",

"(?<dir>[\\-d])(?<permission> ([\\-r][\\-w][\\-xs]){3})\\s+\\d+\\ s+\\w+\\s+\\w+\ \s+(?<size>\\d+ )\\s+(?<timesta mp>\\w+\\s+\\d+ \\s+\\d{1,2}:\\ d{2})\\s+(?<nam e>.+)",

"(?<dir>[\\-d])(?<permission> ([\\-r][\\-w][\\-xs]){3})(\\s+)(?<s ize>(\\d+))(\\s +)(?<ctbit>(\\w +\\s\\w+))(\\s+ )(?<size2>(\\d+ ))\\s+(?<timest amp>\\w+\\s+\\d +\\s+\\d{2}:\\d {2})\\s+(?<name >.+)",

"(?<timestamp>\ \d{2}\\-\\d{2}\\-\\d{2}\\s+\\d{2 }:\\d{2}[Aa|Pp][mM])\\s+(?<dir>\\< \\w+\\>){0,1}(? <size>\\d+){0,1 }\\s+(?<name>.+ )"
};

#endregion

}

#endregion

#region "FTP Directory class"

/// <summary>

/// Stores a list of files and directories from an FTP result

/// </summary>

/// <remarks></remarks>

public class FTPdirectory : List<FTPfileInf o>

{

public FTPdirectory()

{

//creates a blank directory listing

}

/// <summary>

/// Constructor: create list from a (detailed) directory string

/// </summary>

/// <param name="dir">dire ctory listing string</param>

/// <param name="path"></param>

/// <remarks></remarks>

public FTPdirectory(st ring dir, string path)

{

foreach (string line in dir.Replace("\n ",
"").Split(Syste m.Convert.ToCha r('\r')))

{

//parse

if (line != "")

{

this.Add(new FTPfileInfo(lin e, path));

}

}

}

/// <summary>

/// Filter out only files from directory listing

/// </summary>

/// <param name="ext">opti onal file extension filter</param>

/// <returns>FTPdir ectory listing</returns>

public FTPdirectory GetFiles(string ext)

{

return this.GetFileOrD ir(FTPfileInfo. DirectoryEntryT ypes.File, ext);

}

/// <summary>

/// Returns a list of only subdirectories

/// </summary>

/// <returns>FTPDir ectory list</returns>

/// <remarks></remarks>

public FTPdirectory GetDirectories( )

{

return this.GetFileOrD ir(FTPfileInfo. DirectoryEntryT ypes.Directory, "");

}

//internal: share use function for GetDirectories/Files

private FTPdirectory GetFileOrDir(FT PfileInfo.Direc toryEntryTypes type,
string ext)

{

FTPdirectory result = new FTPdirectory();

foreach (FTPfileInfo fi in this)

{

if (fi.FileType == type)

{

if (ext == "")

{

result.Add(fi);

}

else if (ext == fi.Extension)

{

result.Add(fi);

}

}

}

return result;

}

public bool FileExists(stri ng filename)

{

foreach (FTPfileInfo ftpfile in this)

{

if (ftpfile.Filena me == filename)

{

return true;

}

}

return false;

}

private const char slash = '/';

public static string GetParentDirect ory(string dir)

{

string tmp = dir.TrimEnd(sla sh);

int i = tmp.LastIndexOf (slash);

if (i 0)

{

return tmp.Substring(0 , i - 1);

}

else

{

throw (new ApplicationExce ption("No parent for root"));

}

}

}

#endregion

}


Feb 19 '07 #1
3 14051
Hi,

>
Has anyone got any Idea why this might happen and how to solve it?
I have a similar message from time to time. IMO it happens at the closing of
the connection. usually you can just ignore them


Feb 19 '07 #2
The problem is only half of the file is uploaded when it happens.

Why does it happen?

Surely its a problem.

Thanks,

"Ignacio Machin ( .NET/ C# MVP )" <machin TA laceupsolutions .comwrote in
message news:ex******** *****@TK2MSFTNG P05.phx.gbl...
Hi,

>>
Has anyone got any Idea why this might happen and how to solve it?

I have a similar message from time to time. IMO it happens at the closing
of the connection. usually you can just ignore them


Feb 19 '07 #3
I had to add a retry logic to resolve it. I basically waited for 1 second
before retrying. I retry up 60 times. So far have not seen the error.

Thanks again,

"Ignacio Machin ( .NET/ C# MVP )" <machin TA laceupsolutions .comwrote in
message news:ex******** *****@TK2MSFTNG P05.phx.gbl...
Hi,

>>
Has anyone got any Idea why this might happen and how to solve it?

I have a similar message from time to time. IMO it happens at the closing
of the connection. usually you can just ignore them


Feb 19 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
4431
by: Mike Dole | last post by:
I'm working on a client - server application based on the 'How to Sockets Server and How to Sockets Client' code from the Visual Basic ..NET Resource Kit. Since I want to be able to send 'big strings' instead of 'one liners' I check the streams for terminators. I'm having problems with the connection, I've been looking and debugging for 2 weeks now (debugging with an emulator is terribly slow..) but I'm not getting it...
0
9973
by: Steve - DND | last post by:
We are continually receiving timeout, and "Unable to write data to the transport connection" errors while using the System.Net.HttpWebRequest class from an ASP.Net web page. Below are the two errors we continue to receive: Source: System Message: The operation has timed-out. Target Function: System.Net.WebResponse GetResponse()
1
4186
by: Muscha | last post by:
Hello, Every now and then my application throw this exception: "Unable to read data from the transport connection" And when I break into the Visual Studio, the thread where it failed has none of my code and the following is the call stack:
0
1615
by: DT | last post by:
We have service oriented architecture that comprises of a number of Win2k/IIS boxes. Some of these web service applications access an AS400 system for data acess (We are using HitSoftware's Ritmo .net native driver). For fail over we route these requests through a hardware based load balancer (BigIP). The BigIP allows us to fail over to a secondary AS400 system in case the primary one fails.
1
2420
by: dina_vr | last post by:
Hi All, I am getting lot of System.IO.IOException: Unable to write data to the transport connection. exceptions when I write to a Stream which is connected to a Remote HTTPS server using a proxy and a certificate. ASCIIEncoding encoding = new ASCIIEncoding(); byte data = encoding.GetBytes(..........);
0
11243
by: Aryeh Holzer | last post by:
Hi, I've been trying to use the weather webservice available from the National Weather Service (NWS), at http://www.nws.noaa.gov/forecasts/xml/DWMLgen/wsdl/ndfdXML. wsdl without success. Here's what I've found so far. When I use .NET 1.0/1.1, and try to call the primary webservice method NDFDgen, the call will succeed if the productType is set to "glance", but fail if set to "time- series".
1
4024
by: Terrance | last post by:
I'm trying to create a small messenger program that uses the tcpclient and tcplistenter objects. When I start the application and run the thread that fires the tcplistener; once the client sends data then closes the stream and the connection I receive the message Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. How can I keep the connection listener listening for new traffic?...
0
789
by: Buddy Home | last post by:
Hello, I'm trying to upload a file programatically and occasionally I get the following error message. Unable to write data to the transport connection: An established connection was aborted by the software in your host machine. Stack Trace at System.Net.Sockets.NetworkStream.Write(Byte buffer, Int32 offset, Int32
6
8161
Cintury
by: Cintury | last post by:
Hi all, I've developed a mobile application for windows mobile 5.0 that has been in use for a while (1 year and a couple of months). It was developed in visual studios 2005 with a back-end sql server mobile ce database. Until recently I was synching everything thru a com port serial cable. The devices would connect to the computer thru activesync and are able to acquire an internet connection. The sync for the program occurs thru a website...
0
8683
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8611
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9031
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8904
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8876
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6531
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5867
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4372
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.