MATLAB Web App Server 2023

15 visualizzazioni (ultimi 30 giorni)
C. K.
C. K. il 20 Nov 2023
Risposto: C. K. il 15 Mar 2024
Dear MATLAB users,
i got some problems, when I'm trying to update the MATLAB Web App Server and some Web Apps from r2020b to r2023b.
1) sendmail function: Is this function not available on MATLAB Web App Server anymore, only local?
code:
subject = ['Subject xyz];
setpref('Internet','SMTP_Server','smtprelay.dmycompany.local');
setpref('Internet','E_mail','xyz@mycompany.com');
mail.Body = sprintf('This is a test.');
sendmail(user@gmail.com, subject, mail.Body, test1.pdf);
error:
2023-11-20 18:01:46 Error using matlab.internal.lang.capability.Capability.require
2023-11-20 18:01:46 This functionality is not available on remote platforms.
2023-11-20 18:01:46 Error in sendmail (line 38)
2) WebSockets protocol? I didn't get this error in the older version.
WebSockets protocol was not established. This may cause performance degradation and occasional errors. Contact your System Administrator
Could you please help me?
Kind regards

Risposta accettata

C. K.
C. K. il 15 Mar 2024
I finally solved the problem. In the browser development tools there was an error message saying that the "WebSocket failed with code: 6". This indicates that Web App Server failed to validate the origin of the request. This check was implemented in MATLAB R2021b to prevent cross-site hijacking. One cause of failure is if the protocol from the origin (e.g.: reverse proxy server) does not match the protocol of the Web App Server.
The solution is the following:
If possible, try setting up the Web App Server such that it is on HTTPS mode with SSL enabled. You can do so by following one of the two MATLAB documentation pages below:
Production version: https://www.mathworks.com/help/webappserver/ug/enable-ssl.html
To find out, whether you use the Production oder the Development of MATLAB Web App Server:
If it is the production version, what is the license number? You can find a list of your software licenses by going to your account on the MathWorks site.

Più risposte (1)

Sanchari
Sanchari il 29 Nov 2023
Hello C.K.,
I understand that you are trying to fix the errors related to MATLAB Web App Server.
The error messages you provided indicate that the “sendmail” function is not available on remote platforms. When working in a remote environment, you may encounter restrictions on certain functions or capabilities due to security or system limitations. In this case, the “sendmail” function is being restricted by the capabilities of the remote platform.
To address this issue, consider the following steps:
  1. Enable less-secure app access feature for Google: To send an email through your Gmail account you must turn off the app security which greatly reduces the security of your Gmail account. One solution to this problem is creating a new Gmail account for the sole purpose of sending emails from this script. This link provides information on how to enable the less-secure app access, https://support.google.com/accounts/answer/6010255. To turn off app security, sign into gmail and access this link: https://myaccount.google.com/lesssecureapps.
  2. Disable AntiVirus: Turn off AntiVirus after implementing the above step. Also, disable the two step verification, if it shows. This should help to fix the error with WebSocket protocol.
  3. Example code: You can follow the example code below.
% User input
source = 'myFakeEmail@gmail.com'; %from address (gmail)
destination = 'kofte@foobar.com'; %to address (any mail service)
myEmailPassword = 'sifre123'; %the password to the 'from' account
subj = 'This is the subject line of the email'; % subject line
msg = 'This is the main body of the email.'; % main body of email.
%set up SMTP service for Gmail
setpref('Internet','E_mail',source);
setpref('Internet','SMTP_Server','smtp.gmail.com');
setpref('Internet','SMTP_Username',source);
setpref('Internet','SMTP_Password',myEmailPassword);
% Gmail server.
props = java.lang.System.getProperties;
props.setProperty('mail.smtp.auth','true');
props.setProperty('mail.smtp.socketFactory.class', 'javax.net.ssl.SSLSocketFactory');
props.setProperty('mail.smtp.socketFactory.port','465');
% Send the email
sendmail(destination,subj,msg);
% [Optional] Remove the preferences (for privacy reasons)
setpref('Internet','E_mail','');
setpref('Internet','SMTP_Server','''');
setpref('Internet','SMTP_Username','');
setpref('Internet','SMTP_Password','');
The “sendmail” function should be able to work after that.
Please refer the documentation for “sendmail” function to use with email servers that require authentication, like gmail, here: https://www.mathworks.com/help/matlab/ref/sendmail.html
Please refer the following ML Answers Learning for further clarification with issues regarding sendmail function:
  1. Sending E-mail error: https://www.mathworks.com/matlabcentral/answers/433031-sending-e-mail-error?s_tid=srchtitle#answer_349841
  2. Sending mail from gmail using sendmail() after authenticating less secure apps access on Google: https://www.mathworks.com/matlabcentral/answers/464564-sending-mail-from-gmail-using-sendmail?s_tid=srchtitle
  3. Send Email using gmail failed: https://www.mathworks.com/matlabcentral/answers/541514-send-email-using-gmail-failed
  4. Valid base error problem in sending email for matlab: https://www.mathworks.com/matlabcentral/answers/484098-base-error-problem-in-sending-email-for-matlab?s_tid=srchtitle
  5. Using gmail after May 30, 2022: https://www.mathworks.com/matlabcentral/answers/1672544-using-gmail-after-may-30-2022?s_tid=srchtitle
Hope this information is helpful to you!
  2 Commenti
C. K.
C. K. il 29 Nov 2023
Modificato: C. K. il 13 Mar 2024
Hi Sanchari,
I solved the problem with sendmail by using the r2020b sendmail function in r2023b.
I'm still not able to fix the websockets error.
kind regards
Christian
Thomas Watson
Thomas Watson il 30 Nov 2023
Hi @Sanchari, is there a more technical explanation or list of troubleshooting steps concerning the WebSocket protocol issue that doesn't involve disabling AntiVirus software? Thank you

Accedi per commentare.

Categorie

Scopri di più su MATLAB Web App Server in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by