C #을 사용하여 FileZilla 서버에 FTPS 연결을 시도하고 있지만 C # 앱이 서버에 로그인하지 않고 서버가 연결을 닫고 C #에서 다음 오류가 표시됩니다.
The underlying connection was closed: The server committed a protocol violation.
내 C # 코드는 다음과 같습니다.
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
var req = (FtpWebRequest)WebRequest.Create("ftp://<my IP>:<my port>/");
req.UsePassive = true;
req.UseBinary = true;
req.EnableSsl = true;
req.KeepAlive = true;
req.Credentials = new NetworkCredential("Puff", "Daddy");
req.Method = WebRequestMethods.Ftp.ListDirectory;
using (var response = (FtpWebResponse)req.GetResponse())
{
//Do Something
}
연결을 시도하면 FileZilla 서버 인터페이스는 다음을 인쇄합니다.
C # 네트워크 로그는 다음과 같이 읽습니다.
System.Net.Sockets Verbose: 0 : [6424] Socket#54135081::Socket(AddressFamily#23)
System.Net.Sockets Verbose: 0 : [6424] Exiting Socket#54135081::Socket()
System.Net.Sockets Verbose: 0 : [6424] DNS::TryInternalResolve(<FTP Server IP>)
System.Net.Sockets Verbose: 0 : [6424] Socket#5773521::Connect(<FTP Server IP>:<FTP Port>#-1925092664)
System.Net.Sockets Information: 0 : [6424] Socket#5773521 - Created connection from <local IP>:61169 to <Server IP>:<Server Port>.
System.Net.Sockets Verbose: 0 : [6424] Exiting Socket#5773521::Connect()
System.Net.Sockets Verbose: 0 : [6424] Socket#54135081::Close()
System.Net.Sockets Verbose: 0 : [6424] Socket#54135081::Dispose()
System.Net.Sockets Verbose: 0 : [6424] Exiting Socket#54135081::Close()
System.Net Information: 0 : [6424] FtpControlStream#63094882 - Created connection from <Local IP>:61169 to <Server IP>:<Server Port>.
System.Net Information: 0 : [6424] Associating FtpWebRequest#59817589 with FtpControlStream#63094882
System.Net.Sockets Verbose: 0 : [6424] Socket#5773521::Receive()
System.Net.Sockets Verbose: 0 : [6424] Data from Socket#5773521::Receive
System.Net.Sockets Verbose: 0 : [6424] 00000000 : :
System.Net.Sockets Verbose: 0 : [6424] Exiting Socket#5773521::Receive() -> Int32#0
System.Net.Sockets Verbose: 0 : [6424] Socket#5773521::Dispose()
System.Net Information: 0 : [6424] FtpWebRequest#59817589::(Releasing FTP connection#63094882.)
System.Net Error: 0 : [6424] Exception in FtpWebRequest#59817589::GetResponse - The underlying connection was closed: The server committed a protocol violation.
FileZilla 클라이언트를 사용하여 동일한 PC에서 동일한 매개 변수로 성공적으로 연결 했으므로 작동해야한다는 것을 알고 있습니다.
이 줄을 App.Config에 추가했습니다.
<system.net>
<settings>
<servicePointManager expect100Continue="false"/>
<httpWebRequest useUnsafeHeaderParsing="true"/>
</settings>
</system.net>
또한 .NET Framework 3.5 및 2.0을 대상으로 시도했지만 둘 다 동일한 결과를 얻었습니다. 현재 .NET 4.6을 실행하고 있습니다. 서버 인증서 등을 설치해야합니까? 아니면 코드가 잘못 되었습니까?
이 질문을 게시 한 지 약 2 분 후에 답이 나왔습니다. 다른 사람이 이러한 어려움을 겪을 경우를 대비하여 남겨 둘 것입니다 (나는 때때로 누군가가 내 문제를 공유한다는 생각을 좋아하지만 그럴 가능성은 낮습니다).
FileZilla 서버의 "FTP over TLS 설정"대화 상자에서 암시 적 FTP 또는 TLS를 수신하도록 포트를 구성했습니다 (기본값은 990). 이것은 FZ 클라이언트 FTPS 연결에서 사용한 포트였습니다. 또한 연결이 명시 적 FTPS이기 때문에 작동하지 않는 C #에서이 포트를 사용하려고했습니다. 일반 설정에 지정된 포트를 수신 포트 (기본값 21)로 사용해야했습니다.
질문을 게시하기 전에 실제로 시도했지만 라우터 구성을 적용하는 것을 잊었으므로 작동하지 않습니다. "Der".
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다