Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Is there a way to receive failed email exceptions?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Is there a way to receive failed email exceptions?

    I am running several strategies and indicators that use NinjaTrader's internal email module to send me and some subs notification alerts. Today no emails were received for a few hours and suddenly it worked again. Now while I try to dissect where things broke down I am also trying to figure out if there is a way to receive exceptions should sending an email fail.

    What is the default behavior for NinjaTrader if sending emails does not work? For instance what happens if the port isn't open or if the email server cannot be contacted? I didn't see any errors in the logs - the emails simply didn't arrive. Now, I don't think it's Ninja but I would like to figure out how to trace the problem next time this happens.

    Thanks in advance.

    #2
    Hello molecool,
    This is a excellent question.

    Currently the SendMail() function is a void type function so unfortunately there is no returned value to check if it has completed or not.

    The only other thing you may be able to do is create your own sendmail method in the strategy you are using by using the System.Web.Mail.MailMessage namespace.

    This wouldn't be something that would be supported by Ninjatrader, but you can certainly read more on the subject and see what you can work out.

    Here is a MSDN article of users that have used System.Web.Mail.MailMessage to build a new message. http://social.msdn.microsoft.com/For...um=netfxnetcom

    Please let me know if I may be of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Jesse View Post
      Hello molecool,
      This is a excellent question.

      Currently the SendMail() function is a void type function so unfortunately there is no returned value to check if it has completed or not.

      The only other thing you may be able to do is create your own sendmail method in the strategy you are using by using the System.Web.Mail.MailMessage namespace.

      This wouldn't be something that would be supported by Ninjatrader, but you can certainly read more on the subject and see what you can work out.

      Here is a MSDN article of users that have used System.Web.Mail.MailMessage to build a new message. http://social.msdn.microsoft.com/For...um=netfxnetcom

      Please let me know if I may be of further assistance.
      Thanks - this confirms what I suspected. Frankly speaking - until now there never was the need as it has worked very well for years. But I may have to resort to this if I see it happen again. Appreciate the feedback.

      Comment


        #4
        Follow up question - assuming the SMTP gateway refuses to send emails a number of times. Is it possible that NinjaTrader internally would stop sending them without throwing an error? My hosting company told me that the IP running NinjaTrader may have been blocked. But I never received any errors in the console or in my trace. What is the default behavior if SMTP refuses to accept emails or ignores them? I know this is a tough question as email is a fur-ball in its own reign.

        Comment


          #5
          Hello molecool,

          With the SendMail() method if NinjaTrader encounters a local sending problem, it does post an error to the log. I will attach an image of the error for reference. NinjaTrader will attempt to re-send the mail every time the SendMail() is called unless you are in Historical.

          If the problem is in between NinjaTrader and the server it is possible there may be a message in the trace files about this but there will be no notification or alert of any sort. Basically you would need to search through manually to see if there is anything listed. It would keep trying to send the mail when the SendMail() is called even if it is not going through, it just would not be sent.

          Please let me know if I may be of further assistance.
          Attached Files
          JesseNinjaTrader Customer Service

          Comment


            #6
            Originally posted by NinjaTrader_Jesse View Post
            Hello molecool,

            With the SendMail() method if NinjaTrader encounters a local sending problem, it does post an error to the log. I will attach an image of the error for reference. NinjaTrader will attempt to re-send the mail every time the SendMail() is called unless you are in Historical.

            If the problem is in between NinjaTrader and the server it is possible there may be a message in the trace files about this but there will be no notification or alert of any sort. Basically you would need to search through manually to see if there is anything listed. It would keep trying to send the mail when the SendMail() is called even if it is not going through, it just would not be sent.

            Please let me know if I may be of further assistance.
            No I never got that one. My trace says that the routine executed and no errors. So I think what happens is that it sends it out - the mailserver simply ignores it and perhaps doesn't even respond (possibility right?).

            Comment


              #7
              Hello molecool,

              No I never got that one. My trace says that the routine executed and no errors. So I think what happens is that it sends it out - the mail server simply ignores it and perhaps doesn't even respond (possibility right?).
              You are correct with this. If the mail server ignores the request after the message has been sent from NinjaTrader to the server, NinjaTrader would not know of this as there is no returned value from the server to NinjaTrader letting it know if it was successful or not. The SendMail() method would only report errors if it happened locally in the scope that it can see.

              Please let me know if I may be of further assistance.
              JesseNinjaTrader Customer Service

              Comment


                #8
                Circling back

                Hey guys - I wanted to circle back on my email issue. As you recall intermittently Ninja stopped sending them. We were able to confirm that by concurrently monitoring the mailserver as well as the VPS sending them (via Ninja). Another big clue was that emails always resumed for a few hours after relaunching Ninja. Then suddenly (and mostly overnight) nothing was reaching the mailserver anymore and there were no errors in the NT console/logs.

                What I wound up doing was to implement my own thread to send out email via SMTP. I have only been running for a day now but it seems to be working fine. Given this I believe that there is a problem with email delivery - obviously it may be caused by a myriad of issues. It would be extremely difficult for you guys to recreate this as my strategy is rather complex - it uses several backgroundworkers, DLLs, thousands lines of code, etc. There were however no strategy related errors but of course a lot of things can happen under the covers without an error being reported.

                What I would suggest for NT8 is to allow for more constructive logging by the thread that handles email delivery. At minimum errors should be reported if email cannot be sent, if the mailhost is not available, etc. Perhaps you guys are doing that already - I never saw any in four years of using the internal mechanism.

                I hope this feedback is productive. If I can be of any help figuring this out do not hesitate to ask - it cost me over a week of sweat and blood to resolve this and I very much would like to spare someone else the same pain.

                Comment


                  #9
                  Hello molecool,

                  Thanks for the feedback we do appreciate it, I’m glad you were able to get the emails working to your expectations. I can certainly submit a feature request using what you have outlined in your previous post.

                  What I would suggest for NT8 is to allow for more constructive logging by the thread that handles email delivery. At minimum errors should be reported if email cannot be sent, if the mailhost is not available, etc
                  I will post a reply when I receive a confirmation on the submitted request.

                  Thanks again,

                  Please let me know if I may be of further assistance.
                  JesseNinjaTrader Customer Service

                  Comment


                    #10
                    Hello molecool,

                    I just received the ticket number for your feature request and wanted to post it here for your reference.

                    Feature Request #2840

                    Thanks again.
                    Please let me know if I may be of further assistance.
                    JesseNinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by geotrades1, Today, 10:02 AM
                    1 response
                    4 views
                    0 likes
                    Last Post NinjaTrader_BrandonH  
                    Started by ender_wiggum, Today, 09:50 AM
                    1 response
                    5 views
                    0 likes
                    Last Post NinjaTrader_Gaby  
                    Started by rajendrasubedi2023, Today, 09:50 AM
                    1 response
                    12 views
                    0 likes
                    Last Post NinjaTrader_BrandonH  
                    Started by bmartz, Today, 09:30 AM
                    1 response
                    9 views
                    0 likes
                    Last Post NinjaTrader_Erick  
                    Started by geddyisodin, Today, 05:20 AM
                    3 responses
                    26 views
                    0 likes
                    Last Post NinjaTrader_Gaby  
                    Working...
                    X