Skip to content

Getting error `waitfor': timed out while waiting for more data (Net::ReadTimeout) #2

Open

Description

@shashi-we

I have simple script to send emails using ruby telnet library
here is my code

require 'net/telnet'

localhost = Net::Telnet::new("Host" => "smtp.gmail.com","Timeout" => 10, "Port" => 587, "Waittime" => 20, "
FailEOF" => true )
localhost.cmd("mail from: oneperson@gmail.com"){ |c| print c }
localhost.cmd("rcpt to: oneperson@gmail.com"){ |c| print c }
localhost.close

I got this error 'waitfor' timed out while waiting for more data again and again
why I am getting this error again and again, what's wrong in the code snipet?

Activity

  1. Alexey1100 commented on Mar 6, 2017

    @Alexey1100

    You didn't define neither prompt nor match pattern for your cmd.
    Take a look at the example in README.

  2. pommechocolat commented on Jan 23, 2023

    @pommechocolat

    I have a similar issue, but neither "Prompt" or "Match" work. This is because the Telnet server don't send any prompt. And the waitfor in the cmd function send only a Prompt in 0.2.0 version. I made a test in rewriting the cmd function that's give me satisfaction. Is my solution correct ? Could a correction be donne in next version ?

        def cmd(options) # :yield: recvdata
          match    = @options["Prompt"]
          time_out = @options["Timeout"]
          fail_eof = @options["FailEOF"]
          typeMatch = "Prompt"
    
          if options.kind_of?(Hash)
            cmd   = options["Cmd"] if options.has_key?("String")
            if options.has_key?("String")
              match    = options["String"]
              typeMatch="String"
            end
            if options.has_key?("Match")
              match    = options["Match"]
              typeMatch="Match"
            end
            time_out = options["Timeout"] if options.has_key?("Timeout")
            fail_eof = options["FailEOF"] if options.has_key?("FailEOF")
          else
            cmd = options
          end
    
          self.puts(cmd)
          if block_given?
            waitfor({typeMatch => match, "Timeout" => time_out, "FailEOF" => fail_eof}){|c| yield c }
          else
            waitfor({typeMatch => match, "Timeout" => time_out, "FailEOF" => fail_eof})
          end
        end
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions