ThreeMammals / Ocelot

.NET API Gateway
https://www.nuget.org/packages/Ocelot
MIT License
8.28k stars 1.63k forks source link

FTP is raising Exception of Timeout but working in FileZilla and WinSCP #1970

Closed PKYADAV closed 6 months ago

PKYADAV commented 6 months ago

Hi Team,

Trying to upload FTP but getting timeout exception:

2024-02-24 13:58:48.633 +05:30 [ERR] Error while uploading the file to the server. See InnerException for more info. FluentFTP.Exceptions.FtpException: Error while uploading the file to the server. See InnerException for more info. ---> System.TimeoutException: Timed out trying to connect! at FluentFTP.FtpSocketStream.ConnectAsync(String host, Int32 port, FtpIpVersion ipVersions, CancellationToken token) at FluentFTP.AsyncFtpClient.OpenPassiveDataStreamAsync(FtpDataConnectionType type, String command, Int64 restart, CancellationToken token) at FluentFTP.AsyncFtpClient.OpenDataStreamAsync(String command, Int64 restart, CancellationToken token) at FluentFTP.AsyncFtpClient.GetNameListing(String path, CancellationToken token) at FluentFTP.AsyncFtpClient.FileExists(String path, CancellationToken token) at FluentFTP.AsyncFtpClient.UploadFileInternalAsync(Stream fileData, Strin2024-02-24 13:59:26.438 +05:30 [ERR] Error while uploading the file to the server. See InnerException for more info. FluentFTP.Exceptions.FtpException: Error while uploading the file to the server. See InnerException for more info. ---> System.TimeoutException: Timed out trying to read data from the socket stream! at FluentFTP.FtpSocketStream.ReadAsync(Byte[] buffer, Int32 offset, Int32 count, CancellationToken token) at FluentFTP.FtpSocketStream.ReadLineAsync(Encoding encoding, CancellationToken token) at FluentFTP.Client.BaseClient.BaseFtpClient.FluentFTP.IInternalFtpClient.GetReplyInternal(CancellationToken token, String command, Boolean exhaustNoop, Int32 timeOut, Boolean useSema) at FluentFTP.AsyncFtpClient.Execute(String command, CancellationToken token) at FluentFTP.AsyncFtpClient.OpenActiveDataStreamAsync(FtpDataConnectionType type, String command, Int64 restart, CancellationToken token) at FluentFTP.AsyncFtpClient.OpenActiveDataStreamAsync(FtpDataConnectionType type, String command, Int64 restart, CancellationToken token) at FluentFTP.AsyncFtpClient.OpenDataStreamAsync(String command, Int64 restart, CancellationToken token) at FluentFTP.AsyncFtpClient.OpenWriteInternal(String path, FtpDataType type, Int64 fileLen, Boolean ignoreStaleData, CancellationToken token) at FluentFTP.AsyncFtpClient.UploadFileInternalAsync(Stream fileData, String localPath, String remotePath, Boolean createRemoteDir, FtpRemoteExists existsMode, Boolean fileExists, Boolean fileExistsKnown, IProgress`1 progress, CancellationToken token, FtpProgress metaProgress) --- End of inner exception stack trace ---

FTP Logs:

2024-02-24 14:04:28.668 +05:30 [INF] > Connect(False) 2024-02-24 14:04:28.676 +05:30 [DBG] FluentFTP 49.0.1.0(.NET 6.0) 2024-02-24 14:04:28.676 +05:30 [INF] Connecting to IP #1= :21 2024-02-24 14:04:28.679 +05:30 [DBG] Waiting for a response 2024-02-24 14:04:28.684 +05:30 [INF] Response: 220 Welcome to FTP service. [738939.357d] 2024-02-24 14:04:28.684 +05:30 [INF] Command: USER 2024-02-24 14:04:28.684 +05:30 [DBG] Waiting for response to: USER 2024-02-24 14:04:28.687 +05:30 [INF] Response: 331 Please specify the password. [2ms] 2024-02-24 14:04:28.687 +05:30 [INF] Command: PASS 2024-02-24 14:04:28.687 +05:30 [DBG] Waiting for response to: PASS *** 2024-02-24 14:04:28.733 +05:30 [INF] Response: 230 Login successful. [46ms] 2024-02-24 14:04:28.733 +05:30 [INF] Command: FEAT 2024-02-24 14:04:28.733 +05:30 [DBG] Waiting for response to: FEAT 2024-02-24 14:04:28.737 +05:30 [DBG] Response: 211-Features: Response: EPRT Response: EPSV Response: MDTM Response: PASV Response: REST STREAM Response: SIZE Response: TVFS 2024-02-24 14:04:28.737 +05:30 [INF] Response: 211 End [3ms] 2024-02-24 14:04:28.737 +05:30 [INF] Text encoding: System.Text.ASCIIEncoding+ASCIIEncodingSealed 2024-02-24 14:04:28.737 +05:30 [INF] Command: SYST 2024-02-24 14:04:28.737 +05:30 [DBG] Waiting for response to: SYST 2024-02-24 14:04:28.740 +05:30 [INF] Response: 215 UNIX Type: L8 [3ms] 2024-02-24 14:04:28.740 +05:30 [DBG] Active ServerHandler is: None 2024-02-24 14:04:28.740 +05:30 [DBG] Listing parser set to: Unix 2024-02-24 14:04:28.740 +05:30 [INF] Command: PWD 2024-02-24 14:04:28.740 +05:30 [DBG] Waiting for response to: PWD 2024-02-24 14:04:28.744 +05:30 [INF] Response: 257 "/" is the current directory [3ms] 2024-02-24 14:04:28.744 +05:30 [INF] > UploadFile("/srv/nidoworkz/nidoimages/167f32cc-4208-4c47-b25a-66829dc5bf50/Vol_500378308208_20240224140001.png", "Vol_500378308208_20240024020002.png", Overwrite, True, Retry) 2024-02-24 14:04:28.744 +05:30 [INF] > FileExists("Vol_500378308208_20240024020002.png") 2024-02-24 14:04:28.744 +05:30 [INF] Command: SIZE /Vol_500378308208_20240024020002.png 2024-02-24 14:04:28.744 +05:30 [DBG] Waiting for response to: SIZE /Vol_500378308208_20240024020002.png 2024-02-24 14:04:28.747 +05:30 [INF] Response: 550 Could not get file size. [3ms] 2024-02-24 14:04:28.747 +05:30 [INF] > DirectoryExists(".") 2024-02-24 14:04:28.748 +05:30 [INF] > OpenWrite("Vol_500378308208_20240024020002.png", Binary, -1, False) 2024-02-24 14:04:28.748 +05:30 [INF] Command: TYPE I 2024-02-24 14:04:28.748 +05:30 [DBG] Waiting for response to: TYPE I 2024-02-24 14:04:28.751 +05:30 [INF] Response: 200 Switching to Binary mode. [3ms] 2024-02-24 14:04:28.751 +05:30 [INF] > OpenDataStreamAsync("STOR Vol_500378308208_20240024020002.png", 0) 2024-02-24 14:04:28.751 +05:30 [INF] > OpenActiveDataStreamAsync(AutoActive, "STOR Vol_500378308208_20240024020002.png", 0) 2024-02-24 14:04:28.751 +05:30 [INF] Command: EPRT |1|192.168.0.201|41479| 2024-02-24 14:04:28.751 +05:30 [DBG] Waiting for response to: EPRT |1|192.168.0.201|41479| 2024-02-24 14:04:28.755 +05:30 [INF] Response: 500 Illegal EPRT command. [3ms] 2024-02-24 14:04:28.755 +05:30 [DBG] Closing/Disposing FtpSocketStream(data connection) 2024-02-24 14:04:28.755 +05:30 [INF] > OpenActiveDataStreamAsync(PORT, "STOR Vol_500378308208_20240024020002.png", 0) 2024-02-24 14:04:28.755 +05:30 [INF] Command: PORT 192,168,0,201,180,193 2024-02-24 14:04:28.755 +05:30 [DBG] Waiting for response to: PORT 192,168,0,201,180,193

raman-m commented 6 months ago

@PKYADAV Welcome to Ocelot world! :tiger:

Ocelot doesn't support FTP protocol (scheme) officially!

Supported protocols are: http/https and ws/wss :exclamation: We have no ASP.NET pipeline for FTP(S) protocols.

And the reasons of failed connection are

It seems we have a mix of FTP vs Websocks in your user scenario.

Would you like to work on this problem together with us?

Would you like to contribute to add FTP support in Ocelot?


@ggnaegi @RaynaldM FYI

PKYADAV commented 6 months ago

Sorry @raman-m, I posted in wrong repository.

raman-m commented 6 months ago

:rofl: