Dukascopy
 
 
Wiki JStore Search Login

Remote run: sendEmail(...)
 Post subject: how to grant socket permission in remote mode? Post rating: 0   New post Posted: Thu 24 Apr, 2014, 08:41 
User avatar

User rating: 1
Joined: Tue 27 Aug, 2013, 17:39
Posts: 26
Location: China, Shanghai
Dears:
i have write a strategy to send mail in remote mode,but failed,the log is:
Exception:java.security.AccessControlException: access denied ("java.net.SocketPermission" "smtp.163.com" "resolve")
i add the following grant clause to java.policy,but the problem still exist.
permission java.net.SocketPermission "*", "accept,connect,resolve";
anybody can help me?
thanks a lot

btw: local mode is OK


 
 Post subject: Re: how to grant socket permission in remote mode? Post rating: 1   New post Posted: Thu 24 Apr, 2014, 09:04 
User avatar

User rating: 96
Joined: Mon 09 Sep, 2013, 07:09
Posts: 287
Location: Ukraine, SHostka
Forum: strategy on remote server, how to send email?


 
 Post subject: Re: how to grant socket permission in remote mode? Post rating: 1   New post Posted: Fri 25 Apr, 2014, 04:08 
User avatar

User rating: 1
Joined: Tue 27 Aug, 2013, 17:39
Posts: 26
Location: China, Shanghai
hebasto wrote:

thanks for your kindly reply.
i have read this topic before.

quotation:
@Library("mail-1.4.jar")
jar location:
mail-1.4.jar is located in /home/moggy/JForex/Strategies/files/ (my OS is Ubuntu)

add the permission in both files:
/etc/java-6-sun/security/java.policy
/etc/java-6-openjdk/security/java.policy
       // Allow connection to mail server using SMTP
       permission java.net.SocketPermission "*:25", "connect,resolve";
       // Allow connection to mail server using SMTPS
       permission java.net.SocketPermission "*:465", "connect,resolve";

       permission java.net.SocketPermission "*:994", "connect,resolve";

       // Allow connection to mail server using IMAP
       permission java.net.SocketPermission "*:143", "connect,resolve";
       // Allow connection to mail server using IMAPS
       permission java.net.SocketPermission "*:993", "connect,resolve";

       // Allow connection to mail server using POP3
       permission java.net.SocketPermission "*:110", "connect,resolve";
       // Allow connection to mail server using POP3S
       permission java.net.SocketPermission "*:995", "connect,resolve";


sendMail Function:
    public boolean sendMail(String from, String to, String subj, String text)
            throws Exception {
        Properties props = new Properties();
        props.put("mail.smtp.host", smtpServer);
        props.put("mail.smtp.socketFactory.port", "465");
        props.put("mail.smtp.socketFactory.class",
                "javax.net.ssl.SSLSocketFactory");
        props.put("mail.smtp.port", "465");
        props.put("mail.smtp.auth", "true");
        Session session = Session.getDefaultInstance(props, new MailAuth(
                sendermailadd, senderpassword));
        Message msg = new MimeMessage(session);
        msg.setFrom(new InternetAddress(from));
        msg.setRecipients(RecipientType.TO, InternetAddress.parse(to, false));
        msg.setSubject(subj);
        msg.setText(text);
        Transport.send(msg);
        return true;
    }


 
 Post subject: Re: how to grant socket permission in remote mode? Post rating: 2   New post Posted: Fri 25 Apr, 2014, 07:48 
User avatar

User rating: 96
Joined: Mon 09 Sep, 2013, 07:09
Posts: 287
Location: Ukraine, SHostka
I've searched through this forum and find out (Sending an email) that one should use RequiresFullAccess annotation to be allowed send email.
BUT RequiresFullAccess annotation is not allowed in remote strategy code (Remote Run)

In my opinion remote strategy environment is not suitable for such tasks as sending email. And it is not reliable as well (Delay in data feed on Remote Run).


 
 Post subject: Re: how to grant socket permission in remote mode? Post rating: 0   New post Posted: Fri 25 Apr, 2014, 09:50 
User avatar

User rating: 1
Joined: Tue 27 Aug, 2013, 17:39
Posts: 26
Location: China, Shanghai
hebasto wrote:
I've searched through this forum and find out (Sending an email) that one should use RequiresFullAccess annotation to be allowed send email.
BUT RequiresFullAccess annotation is not allowed in remote strategy code (Remote Run)

In my opinion remote strategy environment is not suitable for such tasks as sending email. And it is not reliable as well (Delay in data feed on Remote Run).

Yeah,exactly,maybe it's commercial but not technical reason.


 
 Post subject: Re: how to grant socket permission in remote mode? Post rating: 0   New post Posted: Mon 28 Apr, 2014, 09:12 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
We plan to add mail sending functionality to API in order to facilitate the mail sending routine and enable its usage in the local run. Meanwhile consider broadcasting your message to a local strategy, which thereafter would send the e-mail:
https://www.dukascopy.com/wiki/#Broadcast_message


 
 Post subject: Remote run: log and alert Post rating: 0   New post Posted: Wed 11 Jun, 2014, 14:45 

User rating: 0
Joined: Fri 17 May, 2013, 06:58
Posts: 76
Location: SwedenSweden
Hi,

When doing Remote run on a strategy, what is the preferred way to:
- log (i.e., log to file or console so that I can look and/or retreive the log at any time in the future)? Also, are there any limitations on the log size?
- alert myself (e.g., sending myself an e-mail) when something goes wrong?

Thanks.

Regards,
Henrik


 
 Post subject: Re: Remote run: log and alert Post rating: 2   New post Posted: Wed 11 Jun, 2014, 19:35 
User avatar

User rating: 96
Joined: Mon 09 Sep, 2013, 07:09
Posts: 287
Location: Ukraine, SHostka
whiletrue wrote:
- log (i.e., log to file or console so that I can look and/or retreive the log at any time in the future)?
https://www.dukascopy.com/wiki/#Remote_Run
Wiki wrote:
3. There is no work with files (i.e., java.io.File).
Wiki wrote:
8. IConsole.get*().println() should be called no more often than once per 1ms. Otherwise only the last statement will get logged.
Wiki wrote:
7. Strategy logs don't get written in the platform, rather they can be accessed by selecting in the plaform Portfolio -> Strategy Log.
Be aware that:
Dukascopy does not guarantee you can retrieve the log - Remote Strategy Log is broken
Dukascopy does not guarantee the log will be complete - Remote Strategy Log suppresses output

whiletrue wrote:
Also, are there any limitations on the log size?
Yes, there are. But Dukascopy keep silence about this - Remote Strategy Log size limits

whiletrue wrote:
- alert myself (e.g., sending myself an e-mail) when something goes wrong?
Send e-mail & JFUtils.sendEmail
Broadcast message & IEngine.broadcast
Notification by SMS or email


 
 Post subject: Re: Remote run: log and alert Post rating: 0   New post Posted: Thu 12 Jun, 2014, 11:39 

User rating: 0
Joined: Fri 17 May, 2013, 06:58
Posts: 76
Location: SwedenSweden
Hi again,

Thanks hebasto.

Does Dukascopy provide a smtp server, or do I have to provide one myself? If so, can I use my gmail stmp server? If so, how?

Regards,
Henrik


 
 Post subject: Re: Remote run: log and alert Post rating: 0   New post Posted: Thu 12 Jun, 2014, 11:53 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
whiletrue wrote:
Does Dukascopy provide a smtp server, or do I have to provide one myself?
The latter.
whiletrue wrote:
If so, can I use my gmail stmp server? If so, how?
https://email.about.com/od/accessinggmail/f/Gmail_SMTP_Settings.htm


 
 Post subject: Re: how to grant socket permission in remote mode? Post rating: 0   New post Posted: Fri 13 Jun, 2014, 04:18 
User avatar

User rating: 1
Joined: Tue 27 Aug, 2013, 17:39
Posts: 26
Location: China, Shanghai
the new JDK have add an interface JFUtils.sendEmail to send mail in remote mode.
https://www.dukascopy.com/wiki/#Send_e-mail
it seems that jdk use mail-1.4.jar too~

Now the problem is,when i call myutils.sendMail(smtpServer, from, to, subj, text); it shows exception:
06:19:11 Exception:com.dukascopy.api.JFException: com.sun.mail.smtp.SMTPSendFailedException: 553 You are not authorized to send mail, ...

how to pass the password to JFUtils to authenticate the from mail account?


 
 Post subject: Remote run: sendEmail(...) Post rating: 0   New post Posted: Mon 16 Jun, 2014, 18:00 

User rating: 0
Joined: Fri 17 May, 2013, 06:58
Posts: 76
Location: SwedenSweden
Hi,

How to use JFUtils.sendEmail(...) on Remote run? Should I specify the smtpServer string parameter as:

"<my_email>@gmail.com:<my_password>@smtp.gmail.com:465"

?

Thanks in advance.

Regards,
Henrik

PS. It would be really nice if Dukascopy could provide a smtp server... =)


 
 Post subject: Re: Remote run: sendEmail(...) Post rating: 0   New post Posted: Wed 18 Jun, 2014, 08:18 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
The functionality is not working on Remote at the moment, it will be fixed as soon as possible.


 
 Post subject: Re: Remote run: sendEmail(...) Post rating: 0   New post Posted: Wed 18 Jun, 2014, 11:42 

User rating: 0
Joined: Fri 17 May, 2013, 06:58
Posts: 76
Location: SwedenSweden
Ok, I see.

Please provide a complete example of how to use the JFUtils.sendEmail(...) on Remote run once it works again.

Thanks.

Regards,
Henrik


 
 Post subject: Re: Remote run: sendEmail(...) Post rating: 0   New post Posted: Fri 27 Jun, 2014, 08:36 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Fixed with JForex-API 2.9.12.


 
 Post subject: Re: Remote run: sendEmail(...) Post rating: 0   New post Posted: Mon 30 Jun, 2014, 14:40 

User rating: 0
Joined: Fri 17 May, 2013, 06:58
Posts: 76
Location: SwedenSweden
Great. But how to configure the smtp server when running remotely?

Thanks.

/Henrik


 
 Post subject: Re: Remote run: sendEmail(...) Post rating: 0   New post Posted: Fri 04 Jul, 2014, 02:17 
User avatar

User rating: 1
Joined: Tue 27 Aug, 2013, 17:39
Posts: 26
Location: China, Shanghai
API Support wrote:
Fixed with JForex-API 2.9.12.

2.9.12 seems to be unavailable from the website now.


 
 Post subject: Re: Remote run: sendEmail(...) Post rating: 0   New post Posted: Fri 11 Jul, 2014, 15:43 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Moggy wrote:
2.9.12 seems to be unavailable from the website now.
It has not been released yet.
whiletrue wrote:
But how to configure the smtp server when running remotely?
We are working on this, but it will not be available with 2.9.12.


 
 Post subject: Re: Remote run: sendEmail(...) Post rating: 0   New post Posted: Tue 28 Oct, 2014, 12:34 

User rating: 0
Joined: Fri 17 May, 2013, 06:58
Posts: 76
Location: SwedenSweden
Hi again,

Any progress regarding this matter? Please provide complete code example.

Thanks.

Kind Regards,
Henrik


 
 Post subject: Re: Remote run: sendEmail(...) Post rating: 0   New post Posted: Tue 28 Oct, 2014, 13:32 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
See JavaDoc: https://www.dukascopy.com/client/javadoc/com/dukascopy/api/JFUtils.html#sendMail(java.lang.String,%20java.lang.String,%20java.lang.String)

This should work both local and remote. You don't need to provide smtp server or configure it.


 

Jump to:  

cron
  © 1998-2024 Dukascopy® Bank SA
On-line Currency forex trading with Swiss Forex Broker - ECN Forex Brokerage,
Managed Forex Accounts, introducing forex brokers, Currency Forex Data Feed and News
Currency Forex Trading Platform provided on-line by Dukascopy.com