[RESOLVED] The server committed a protocol violation.
For some reason i am getting this error when I try to upload to my ftp:
Code:
The underlying connection was closed: The server committed a protocol violation.
This happens at the GetRequestStream() portion of the code. here is my code:
Code:
Private Sub FTPUpload(ByVal p_FilePath As String, ByVal p_FTPServer As String, ByVal p_FileNameOnServer As String, _
ByVal p_Username As String, ByVal p_Password As String)
'Reading file into a byte array
Dim file As Byte()
file = System.IO.File.ReadAllBytes(p_FilePath)
'Request
Dim req As System.Net.FtpWebRequest
req = DirectCast(System.Net.WebRequest.Create("ftp://" + p_FTPServer + "/" + p_FileNameOnServer), System.Net.FtpWebRequest)
'Credentials
Dim credentials As New System.Net.NetworkCredential(p_Username, p_Password)
req.Credentials = credentials
'Request Method
req.Method = System.Net.WebRequestMethods.Ftp.UploadFile
'uploading file onto FTP server
Dim stream As System.IO.Stream
stream = req.GetRequestStream()
stream.Write(file, 0, file.Length)
stream.Close()
End Sub
Re: The server committed a protocol violation.
I tested your code out, and it worked fine for me (on a Windows FTP server). Do you have an alternate FTP server you could test on? Are you sure you have write access to the root of the FTP directory structure? Also see if that exception that is being thrown has any extra information in its InnerException property. Sometimes that provides more info on exactly WHY the error occured.
Re: The server committed a protocol violation.
the ftp is on my hosting with godaddy, i have never had any trouble with this code before today.
Re: The server committed a protocol violation.
I'll just throw it out there because I had a weird problem with my FTP uploads from an app we use to upload personalized versions of our software to customers. I could not figure out why the uploads were failing, until I realized the server space allotment had run out. I had to clear out some old files off the FTP server and then all was well.
I feel like godaddy however is usually pretty gratuitous with their storage limits, so that is probably not your issue.
Are you able to download files via FTP code? I do think it is something server specific, since it does work fine for me now, and it did work for you in the past.
Re: The server committed a protocol violation.
wow i accidentally put a space in my ftp settings for the folder the account was assigned to
Re: The server committed a protocol violation.
I take it then it's all working?
Re: The server committed a protocol violation.
yea, just was a stupid mistaake