10060, 'Operation timed out'

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Sumit Acharya

    10060, 'Operation timed out'

    I am using following script to connect to the server and i try the
    connection for 1000 times. Some times it succeeds for all the 1000
    times,but some times it fails with error:-
    10060, 'Operation timed out'. When it fails with the abover error, it
    seems timed out time is 20 seconds. Is there a way I can increase the
    timedout time for FTP?

    from ftplib import FTP
    import time
    import sys

    host = sys.argv[1]
    port = sys.argv[2]

    for x in range(1000):
    try:
    y = time.time()
    ftp = FTP()
    ftp.connect(hos t,port)
    ftp.login('a',' a')
    try:
    print ftp.sendcmd('pa ss x')
    except:
    print sys.exc_value
    ftp.close()
    except:
    print sys.exc_value
    r = time.time()
    print "Timeout %d %d %((r-y),x)

    when there is error in connecting, it comes to the outer except and
    prints the value of r-y as 21. How i can increase this timeout time? or
    this error indicates something else?

    Please let me know asap,

  • Steve Holden

    #2
    Re: 10060, 'Operation timed out'

    Sumit Acharya wrote:[color=blue]
    > I am using following script to connect to the server and i try the
    > connection for 1000 times. Some times it succeeds for all the 1000
    > times,but some times it fails with error:-
    > 10060, 'Operation timed out'. When it fails with the abover error, it
    > seems timed out time is 20 seconds. Is there a way I can increase the
    > timedout time for FTP?
    >
    > from ftplib import FTP
    > import time
    > import sys
    >
    > host = sys.argv[1]
    > port = sys.argv[2]
    >
    > for x in range(1000):
    > try:
    > y = time.time()
    > ftp = FTP()
    > ftp.connect(hos t,port)
    > ftp.login('a',' a')
    > try:
    > print ftp.sendcmd('pa ss x')
    > except:
    > print sys.exc_value
    > ftp.close()
    > except:
    > print sys.exc_value
    > r = time.time()
    > print "Timeout %d %d %((r-y),x)
    >
    > when there is error in connecting, it comes to the outer except and
    > prints the value of r-y as 21. How i can increase this timeout time? or
    > this error indicates something else?
    >
    > Please let me know asap,
    >[/color]
    In a single-threaded program you can import the socket module and then
    use the socket.setdefau lttimeout() function to establish a longer timeout.

    regards
    Steve
    --
    Steve Holden +44 150 684 7255 +1 800 494 3119
    Holden Web LLC www.holdenweb.com
    PyCon TX 2006 www.python.org/pycon/

    Comment

    • Sumit Acharya

      #3
      Re: 10060, 'Operation timed out'

      can u please modify the script that i have posted with your suggestion,
      it will help me to a certain extent.

      Thanks

      Comment

      • Steve Holden

        #4
        Re: 10060, 'Operation timed out'

        Sumit Acharya wrote:[color=blue]
        > can u please modify the script that i have posted with your suggestion,
        > it will help me to a certain extent.
        >
        > Thanks
        >[/color]
        from ftplib import FTP
        import time
        import sys
        import socket

        socket.setdefau lttimeout(60)
        host = sys.argv[1]
        port = sys.argv[2]

        for x in range(1000):
        try:
        y = time.time()
        ftp = FTP()
        ftp.connect(hos t,port)
        ftp.login('a',' a')
        try:
        print ftp.sendcmd('pa ss x')
        except:
        print sys.exc_value
        ftp.close()
        except:
        print sys.exc_value
        r = time.time()
        print "Timeout %d %d %((r-y),x)



        --
        Steve Holden +44 150 684 7255 +1 800 494 3119
        Holden Web LLC www.holdenweb.com
        PyCon TX 2006 www.python.org/pycon/

        Comment

        • Sumit Acharya

          #5
          Re: 10060, 'Operation timed out'

          Hi Steve,

          It didnt help, i am getting same error.

          Comment

          • Steve Holden

            #6
            Re: 10060, 'Operation timed out'

            Sumit Acharya wrote:[color=blue]
            > Hi Steve,
            >
            > It didnt help, i am getting same error.
            >[/color]
            After 20 seconds or 60?

            regards
            Steve
            --
            Steve Holden +44 150 684 7255 +1 800 494 3119
            Holden Web LLC www.holdenweb.com
            PyCon TX 2006 www.python.org/pycon/

            Comment

            • Sumit Acharya

              #7
              Re: 10060, 'Operation timed out'

              After 20 seconds only.

              Comment

              • Steve Holden

                #8
                Re: 10060, 'Operation timed out'

                Sumit Acharya wrote:[color=blue]
                > After 20 seconds only.
                >[/color]
                Of course I now realise there's no default timeout on sockets anyway, so
                that likely wasn't the problem.

                Which statement is failing?

                You would actually get much more information without the try/except
                clauses, as they are stopping the traceback from being printed - if the
                error is occurring deep in the ftplib you will actually see "what and
                where" with a full traceback. Your loop should read:

                for x in range(1000):
                ftp = FTP()
                ftp.connect(hos t,port)
                ftp.login('a',' a')
                print ftp.sendcmd('pa ss x')
                ftp.close()

                Try running the script without both try/excepts and then post the full
                traceback, please. You can forget about the timings for now. It may well
                be an FTP server loading issue, but a traceback will give more information.

                regards
                Steve
                --
                Steve Holden +44 150 684 7255 +1 800 494 3119
                Holden Web LLC www.holdenweb.com
                PyCon TX 2006 www.python.org/pycon/

                Comment

                • Sumit Acharya

                  #9
                  Re: 10060, 'Operation timed out'

                  Hi Steve,

                  Thanks, I have started the run without try and except block, I will
                  update with the findings tomm.
                  Please keep this thread on for you so that I can get the solution

                  Comment

                  • Sumit Acharya

                    #10
                    Re: 10060, 'Operation timed out'

                    Hi Steve,
                    this is the trace I have got:-
                    Traceback (most recent call last):
                    File "sumit1.py" , line 39, in ?
                    ftp.connect(hos t,port)
                    File "C:\programs\pa ckages\python24 \lib\ftplib.py" , line 129, in
                    connect
                    raise socket.error, msg
                    socket.error: (10060, 'Operation timed out')

                    Comment

                    • Steve Holden

                      #11
                      Re: 10060, 'Operation timed out'

                      Sumit Acharya wrote:[color=blue]
                      > Hi Steve,
                      > this is the trace I have got:-
                      > Traceback (most recent call last):
                      > File "sumit1.py" , line 39, in ?
                      > ftp.connect(hos t,port)
                      > File "C:\programs\pa ckages\python24 \lib\ftplib.py" , line 129, in
                      > connect
                      > raise socket.error, msg
                      > socket.error: (10060, 'Operation timed out')
                      >[/color]
                      So the FTP server is refusing your connection, I suspect. There's no way
                      the client can control the time it takes to do that.

                      regards
                      Steve
                      --
                      Steve Holden +44 150 684 7255 +1 800 494 3119
                      Holden Web LLC www.holdenweb.com
                      PyCon TX 2006 www.python.org/pycon/

                      Comment

                      • Sumit Acharya

                        #12
                        Re: 10060, 'Operation timed out'

                        Ok, so need to see on the server side.

                        Comment

                        Working...