SMTP – [RST, ACK] TCL Script Issue

Homepage Clovertech Forums Read Only Archives Cloverleaf Cloverleaf SMTP – [RST, ACK] TCL Script Issue

  • Creator
    Topic
  • #55306
    Dave Scoggins
    Participant

    I wrote a tcl script that evaluates ADT messages for line feeds in the DG1 segments. When a line feed is found an email message is sent.

    This script works fine in my development environment both via the testing tool and when I apply the script to Pre Proc routing.

    The script works fine in my production environment via the testing tool but when I apply the script to Pre Proc routing (same as I did in DEV) Cloverleaf appears to be killing the connection to the email server before it even has a chance to send the message to the server.

    When I run a packet trace via Wireshark I can clearly see Cloverleaf is sending a Reset ACK message to the email server thus terminating that connection. (see attachment)

    Here is the snippet of the code that sends the email:

     if {[regexp {x0a} $dg1_03] || [regexp {x0a} $dg1_04]} {

            package require mime

            package require smtp

            package require html

            set msg [string map

      $msg]

              set msg [string map

      $msg]

         

              set token [mime::initialize -canonical text/html -string “Account $pid_18_01 contains carriage returns in at least one of the diagnosis fields. Please review and correct.

      $msg
      “]

               

              mime::setheader $token Subject “Account $pid_18_01 contains carriage returns in at least one of the diagnosis fields. Please review and correct.”

              smtp::sendmessage $token -servers

    • -ports
    • -header
      -header

              mime::finalize $token

       }

      Any ideas why this would work fine in DEV via testing tool and routing and in PROD via the testing tool but has issues when applied to a route in PROD?

      Thanks in advance for your help.

Viewing 3 reply threads
  • Author
    Replies
    • #84912
      David Barr
      Participant

      Is there anything in the process log? Can you turn up the log level while it is failing?

      The testing tool is usually started from the host server. Maybe there’s something different about how the host server was started than the hciengine process that your code is running from (environment, how long it’s been running, etc.).

      Have you tried restarting the engine process from the command line? Can you try running your hcitpstest command from the command line (copy and paste from the testing tool)?

    • #84913
      Dave Scoggins
      Participant

      Hi David

      I enabled all on the logs and reran the message through the route so it would fail. The log increased logging doesn’t give me any more usable information than the regular logging  provided. Good thought though.

      I checked both the DEV and PROD environments to see if I could determine any differences between the two and I can’t find anything. The user account that’s running the hciengine, hcihostserver and hciservice processes is the same in both environments. We are running the same version of Cloverleaf, adapters, etc. in both environments.

      I took your advice to restart the engine process form the command line. That didn’t resolve the issue. I was able to test the tcl script via the hcitpstest command successfully – I did get the email I would have expected.

      I’m thinking there’s something to your second comment but I just can’t figure out what the difference might be. If I create a TCL script in Cloverleaf and save it such that it’s in the TCL script folder and apply that script to a route, then the account that’s running the process should also run the script without issue. In fact, it does run the script without issue because I can comment out the “smtp::sendmessage” line and throw in a few echo statements to see what the output would be and I can see the script does run without issue.

      There’s just something with the actual attempt to send the email.

      What’s also a little perplexing is we have alerts set up in PROD that send email notices and those work just fine. So why do the alerts work fine but the script doesn’t? I realize the alerts and my scripts are two different animals but Cloverleaf is handling all of those, i.e. these are not being run outside of Cloverleaf.

    • #84914
      David Barr
      Participant

      You might want to look at this article.

      <a href="http://stackoverflow.com/questions/7355727/tcl-email-script-doesnt-deliver-in-activestate-tcl&#8221; class=”bbcode_url”>http://stackoverflow.com/questions/7355727/tcl-email-script-doesnt-deliver-in-activestate-tcl

      Passing -debug 1 in your smtp::sendmessage might provide more information.

      I think I ran into the exact problem  that you’re having in the past and this is how I fixed it. Basically I pass the message off to sendmail instead of doing the SMTP submission directly.

      Code:

         package require mime
         package require smtp

         set fp [open report.ps w]
         puts -nonewline $fp $psmsg
         close $fp
         exec ksh -c “unset SHLIB_PATH; gs -sDEVICE=pdfwrite -sOutputFile=report.pdf report.ps < /dev/null"
         set psmsg [read_file report.pdf]

         # create an image and text
         set psT [mime::initialize -canonical
                      "application/pdf; name="report.pdf"" -string $psmsg]
         set textT [mime::initialize -canonical text/plain -string $body]

         # create a multipart containing both, and a timestamp
         set multiT [mime::initialize -canonical multipart/mixed
                         -parts [list $psT $textT]]

         # call Sendmail to deliver the message
         set rcpt [list "david_barr@valleymed.org"]
         set rcpt2 [join $rcpt " "]
         set fp [open "|/usr/sbin/sendmail $rcpt2" w]
         puts $fp "To: [join $rcpt ,]"
         puts $fp "From: "VMC.QDX Integrator production mode." ”
         puts $fp “Subject: error processing report from Penrad”
         #Date: Wed, 02 Mar 2008 16:34:00 -0700
         puts $fp [::mime::buildmessage $multiT]
         close $fp

    • #84915
      Dave Scoggins
      Participant

      Hi David. I checked out the article. I turned on debug but it didn’t provide really any additional details in the log file.

      I’m thinking I’m going to have to find a workaround for this issue. I have a case open with Infor to help me troubleshoot what the issue may be. The case apparently went to development and I’m waiting for word back. It looks like you’re using unix; we’re on Windows here. I don’t know if I can call a sendmail type command in Windows. I’ll have to poke around.

      I did try sending an email via telnet from our Cloverleaf PROD server to our exchange server and I was able to do so…even though my test message was blank when I received it. No matter, I was just trying to test to make sure I could send an email without issue. I looked into using PowerShell to send an email but our servers are locked down where we can’t run PS scripts. I could probably get that changed but I’m just hoping to use the smtp::sendmail function as it’s clean and easy and I already have it built, i.e. I wouldn’t have to work around the issue.

Viewing 3 reply threads
  • The forum ‘Cloverleaf’ is closed to new topics and replies.

Forum Statistics

Registered Users
5,129
Forums
28
Topics
9,301
Replies
34,447
Topic Tags
288
Empty Topic Tags
10