Jump to content

[solved] _FTP_Connect() has a delay of around 20 seconds. Why? --> it was TCP/IP V6


Go to solution Solved by NewCommer,

Recommended Posts

Posted (edited)

Edit: Problem solved

 

I would like to upload data to my server via FTP. Each time there is a delay of around 20 seconds. After that, the transfer works properly.
When I work with Filezilla this delay does not occur.
Here is an executable excerpt, of course with the wrong password.
But the delay can also be seen here:

#include <FTPEx.au3>

Exit _main()

Func _main()
    Local $sServer = 'home515426626.1and1-data.host'
    Local $sUsername = 'u76297179'
    Local $sPass = 'is_intentionally_wrong'
    Local $hOpen = _FTP_Open('myFTP')
    Local $Err, $sFTP_Message
    ConsoleWrite("Before _FTP_Connect ..." & @CRLF)
    Beep(1000, 100)
    $timer = TimerInit()
    Local $hConn = _FTP_Connect($hOpen, $sServer, $sUsername, $sPass)
    ConsoleWrite("After _FTP_Connect ..." & @CRLF)
    ConsoleWrite("TimerDiff() in milleseconds: " & TimerDiff($timer) & @CRLF)
    _FTP_GetLastResponseInfo($Err, $sFTP_Message)
    ConsoleWrite('$Err=' & $Err & '   $sFTP_Message:' & @CRLF & $sFTP_Message & @CRLF)
    Local $iFtpc = _FTP_Close($hConn)
    Local $iFtpo = _FTP_Close($hOpen)
    Beep(1000, 100)
EndFunc   ;==>_main

Here is the result:

Before _FTP_Connect ...
After _FTP_Connect ...
TimerDiff() in milleseconds: 23551.2854
$Err=0   $sFTP_Message:
220 FTP Server ready.
331 Password required for u76297179
530 Login incorrect.

Does anyone has any idea what that could be?

Thanks in advance
@Exit

Edited by Exit
Proplem solved

App: Au3toCmd              UDF: _SingleScript()                             

Posted

For what it is worth, from Australia, I get;

TimerDiff() in milliseconds: 3469.2692217186

 

And, to "ftp.iinet.net.au", I get;

TimerDiff() in milliseconds: 557.259949813836

220 ::ffff:150.101.135.3 FTP server ready

 

 

Phil Seakins

  • Solution
Posted
Hello,
The answer is probably because of ipv6.
[stackoverflow] "I found out that turning off IPV6 protocol in network adapter settings on windows resolved the issue.
So it really could be server side compatibility with IPV6. After 20 sec fallback to IPV4 and any next request running good. Just try turning off the IPV6."
  • Exit changed the title to [solved] _FTP_Connect() has a delay of around 20 seconds. Why? --> it was TCP/IP V6
Posted

@NewCommer You are a champ! 

 

I converted the servername to IPV4 Address and all went OK.
 

Here the proof:

#include <FTPEx.au3>

Exit _main()

Func _main()
    Local $sServer = 'home515426626.1and1-data.host'
    Local $sUsername = 'u76297179'
    Local $sPass = 'is_intentionally_wrong'
    TCPStartup()
    Local $sIPAddress = TCPNameToIP($sServer)
    TCPShutdown()
    ConsoleWrite('IPV4 address of ' & $sServer & ' is ' & $sIPAddress & @CRLF)
    Local $hOpen = _FTP_Open('myFTP')
    Local $Err, $sFTP_Message
    ConsoleWrite("Before _FTP_Connect ..." & @CRLF)
    Beep(1000, 100)
    $timer = TimerInit()
    Local $hConn = _FTP_Connect($hOpen, $sIPAddress, $sUsername, $sPass)
    ConsoleWrite("After _FTP_Connect ..." & @CRLF)
    ConsoleWrite("TimerDiff() in milleseconds: " & TimerDiff($timer) & @CRLF)
    _FTP_GetLastResponseInfo($Err, $sFTP_Message)
    ConsoleWrite('$Err=' & $Err & '   $sFTP_Message:' & @CRLF & $sFTP_Message & @CRLF)
    Local $iFtpc = _FTP_Close($hConn)
    Local $iFtpo = _FTP_Close($hOpen)
    Beep(1000, 100)
EndFunc   ;==>_main

The output:

IPV4 address of home515426626.1and1-data.host is 217.160.122.159
Before _FTP_Connect ...
After _FTP_Connect ...
TimerDiff() in milleseconds: 1848.7934
$Err=0   $sFTP_Message:
220 FTP Server ready.
331 Password required for u76297179
530 Login incorrect.

 

App: Au3toCmd              UDF: _SingleScript()                             

Posted
55 minutes ago, Exit said:

@NewCommer You are a champ! 

I converted the servername to IPV4 Address and all went OK.....

Your method is great.
I use the way to turn off ipv6 manually in Windows Settings, which is quite inconvenient.

I have another new experience from you 😍

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...