Programgod
Member
- Joined
- May 4, 2011
- Messages
- 17
- Programming Experience
- 5-10
I have a rather interesting issue going on with an application that I developed several months ago for the company that I work for. My app goes out to an FTP site and downloads the latest data files then extracts them and imports them into a database. Up until recently the program was working perfectly, but as of a month ago (at least I am assuming based on the dates the files were downloaded last) the FTP connection is failing. I am getting the exception:
Message: Unable to connect to the remote server
Status: ConnectFailure
InnerException: NULL (this is one of the things that bothers me cause it is so vague as to what is actually causing the problem).
I have tried several things such as changing UseBinary, UsePassive, KeepAlive and specifying the port number and connecting by IP versus the FQDN. Nothing is working. And it is not just the site I am trying, it doesn't work with any FTP site I try. Now here is where things get interesting. I AM able to connect to the FTP site via DOS Prompt FTP as well as IE browser. So I know that the site is up and that the firewall/proxy is not blocking connection to it. The other intesting thing is that I wrote up a quick FTP program on my home computer and was able to connect that way. (The only difference between my work computer and home computer is that I am running Win7 at home and WinXP at work, plus the hardware differences but that shouldn't make a difference.) I have also tested attempting to connect using my work computer from outside my workplace network, and it still fails. So the issue is definitely something on my computer, but for the life of me I can not figure out what it is. I have also tried uninstalling all recently automatic updates to the computer, still with no positive results.



Sorry for the novel, but I have been working on this problem for the last couple of days and I am just at my wits end. I have scowered the web looking for a solution or someone that has had the same issue, but with no luck. If anyone can help me I would be incredibly greatful.
Here is my code:
Message: Unable to connect to the remote server
Status: ConnectFailure
InnerException: NULL (this is one of the things that bothers me cause it is so vague as to what is actually causing the problem).
I have tried several things such as changing UseBinary, UsePassive, KeepAlive and specifying the port number and connecting by IP versus the FQDN. Nothing is working. And it is not just the site I am trying, it doesn't work with any FTP site I try. Now here is where things get interesting. I AM able to connect to the FTP site via DOS Prompt FTP as well as IE browser. So I know that the site is up and that the firewall/proxy is not blocking connection to it. The other intesting thing is that I wrote up a quick FTP program on my home computer and was able to connect that way. (The only difference between my work computer and home computer is that I am running Win7 at home and WinXP at work, plus the hardware differences but that shouldn't make a difference.) I have also tested attempting to connect using my work computer from outside my workplace network, and it still fails. So the issue is definitely something on my computer, but for the life of me I can not figure out what it is. I have also tried uninstalling all recently automatic updates to the computer, still with no positive results.
Sorry for the novel, but I have been working on this problem for the last couple of days and I am just at my wits end. I have scowered the web looking for a solution or someone that has had the same issue, but with no luck. If anyone can help me I would be incredibly greatful.
Here is my code:
VB.NET:
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff][/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Imports[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] System.Net
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]
Public[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Class[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Form1
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff] Public[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ftp [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] FtpWebRequest
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff][/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff] Private[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] btnConnect_Click([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] System.Object, [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] btnConnect.Click
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff] Try
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ftp = FtpWebRequest.Create(txtSite.Text)
[URL="ftp://ftp.Credentials"]ftp.Credentials[/URL] = [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] NetworkCredential(txtUserID.Text, txtPassword.Text)
[URL="ftp://ftp.KeepAlive"]ftp.KeepAlive[/URL] = [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]False
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [URL="ftp://ftp.UseBinary"]ftp.UseBinary[/URL] = [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]True
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [URL="ftp://ftp.Method"]ftp.Method[/URL] = WebRequestMethods.Ftp.ListDirectory
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff][/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff] [B][U][COLOR=red]Using[/COLOR][/U][/B][/COLOR][/SIZE][/COLOR][/SIZE][B][U][COLOR=red][SIZE=2] resp [/SIZE][SIZE=2][SIZE=2]As[/SIZE][/SIZE][/COLOR][/U][/B][SIZE=2][B][U][COLOR=red] WebResponse = [URL="ftp://ftp.GetResponse"]ftp.GetResponse[/URL]() <--- This is where the error occurrs[/COLOR][/U][/B]
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff] Using[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] strm [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] IO.Stream = resp.GetResponseStream
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff] Using[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] sread [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] IO.StreamReader = [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] IO.StreamReader(strm)
txtResponse.Text = sread.ReadToEnd
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff] End[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Using
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff] End[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Using
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff] End[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Using
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff] Catch[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] wex [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] WebException
txtResponse.Text = wex.Message
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff] End[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Try
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff] End[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Sub
End[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Class
[/COLOR][/SIZE][/COLOR][/SIZE]
Last edited: