Results 1 to 7 of 7

Thread: [RESOLVED] The server committed a protocol violation.

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2008
    Posts
    84

    Resolved [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

  2. #2
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    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.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jul 2008
    Posts
    84

    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.

  4. #4
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    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.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Jul 2008
    Posts
    84

    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

  6. #6
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: The server committed a protocol violation.

    I take it then it's all working?

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Jul 2008
    Posts
    84

    Re: The server committed a protocol violation.

    yea, just was a stupid mistaake

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width