Results 1 to 3 of 3

Thread: Getting CONNREFUSED error while sending mail using RWSmtpClient

  1. #1
    Junior Member
    Join Date
    Jun 2008

    Getting CONNREFUSED error while sending mail using RWSmtpClient

    I am using RWSmtpclient to send mails to the user. It works fine 99% of the time. But lately, some users are sporadically getting the below errors

    RWSocketError: in RWSocket::connect::CONNREFUSED

    I am using the same code as what the API suggests -


    RWSmtpClient client; // SMTP client object
    RWSmtpReply reply; // SMTP general reply
    RWSmtpDataReply dReply; // SMTP data reply

    try {
    // Connect to our SMTP server
    reply = client.connect("");

    // Say hello from the local machine
    reply = client.helo("tsunami");

    // Mail From: and To:
    reply = client.mail("");
    reply = client.rcpt("");

    // Send a help message
    dReply = client.dataOpen();
    dReply.portal().sendAtLeast("We've got a problem... \n");
    dReply.portal().sendAtLeast("Please help immediately");

    // Indicate it's the end of the message
    reply = client.dataClose();

    // Send more messages, if you like

    // Finally shut down the connection
    reply = client.quit();
    catch (const RWxmsg& m) {
    cout << "Error : " << m.why() << endl;


    Its seems to me that smtp server refused the connection in this case. But the question is Why ? The same user who reported this error *is* still able to send mails but sometimes this error comes.

    The other qn is - what should be the right approach to handle such errors ? Should I try to re-send the mail in such case ? Or print some more logs for debugging purpose ?


  2. #2
    Junior Member
    Join Date
    Feb 2008
    I couldn't find any wording in the SMTP or TCP standards that describes appropriate behavior when encountering this kind of situation. As far as using the SMTP client, there is always a possibility that a connection may fail for some reason.

    If the connection fails, the best approach is to retry the connection and then proceed with sending the mail. Gomez
    Rogue Wave Software
    Product Manager

  3. #3
    Junior Member
    Join Date
    Jul 2008
    I have been getting similar issues with a client (c#) to server(rw c++) application using sockets. We are unable to reproduce the error but it occurs in production every 10.000 to 15.000 calls. We have not seen this to be stress related.
    If we find anything new I'll post a new message.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts