restFunctionConnector
Description
The RESTFunctionConnector
object manages communication between
MATLAB® and a client application. Get this object from the machine that has your
licensed MATLAB. You can use the connector object to open and close the port on the user
machine, write the communication logs, handle certificates, generate URL endpoints, accept
client requests, and relay responses.
To use a simple function service, create and start a RESTFunctionService
object.
Creation
Description
gets the
existing conn
= restFunctionConnectorRESTFunctionConnector
object. Call the function on the machine
that has your licensed MATLAB.
Properties
Port
— User machine port
9920
(default) | double
User machine port that receives client requests and sends responses, specified as a
double
, in the range between [1025, 65535]. This value is used in
the BaseUrl
endpoint.
LogLocation
— Log folder
"<mwPath>/restfcnconnector/logs"
(default) | string scalar
Log folder where service logs are written, specified as a string scalar. For
information about <mwPath>
, see Pathname Displays <mwPath>.
Example:
"C:\Users\myname\AppData\Local\MathWorks\restfcnconnector\logs"
HostName
— Hostname
""
(default) | string scalar
Hostname or IP address, specified as a string scalar. This value is used in the BaseUrl endpoint.
Example:
"localhost"
ClientAccessMode
— Access mode
"local"
(default) | "remote"
Access mode, specified as "local"
or "remote"
.
Use this property to control whether local or remote clients can access the function
connector.
Example:
ClientAccessMode="remote"
ServiceNames
— Names of running function services
string vector
This property is read-only.
Names of the running function services registered with the function connector,
returned as a string vector. To register a service, call the start
function on a RESTFunctionService
object.
RESTPersonalAccessToken
— Client request token
string scalar
This property is read-only.
Client request token, returned as a string scalar. The connector object uses this
token to authenticate client requests. Use this value in the client request HTTP header
field mwRESTPersonalAccessToken
. Requests without a token or with an
invalid token are declined.
Example:
"AQIDBAUGBwgJCgsMDQ4PEBESExQVFhcYGRobHB0eHyA="
TokenExpirationDate
— Expiration date of token
datetime scalar
This property is read-only.
Expiration date of the client request token, returned as a datetime scalar in
dd-mm-yyyy
format. The default lifetime of a token is 30
days.
Example: 05-Dec-2024
Certificate
— Certificate pathname
string scalar
This property is read-only.
Certificate pathname, returned as a string scalar. Client applications use this
certificate (.pem
) file to make requests to the connector over HTTPS.
Copy this certificate to your client application.
Example: "C:\Users\myname\AppData\Local\MathWorks\restfcnconnector\publickey.pem"
CertificateExpirationDate
— Expiration date of certificate
datetime scalar
This property is read-only.
Expiration date of the certificate, returned as a datetime scalar in
dd-mm-yyyy
format.
Example:
15-Dec-2024
BaseUrl
— URL endpoint
string scalar
This property is read-only.
URL endpoint for listening for and making requests from client applications over HTTPS, returned as a string scalar.
Example:
"https://localhost:9920/matlab/feval/v1/EL"
Status
— Service status
notrunning
(default) | running
This property is read-only.
Service status, returned as notrunning
or
running
. This property indicates whether the service has been
started and can receive client requests.
Object Functions
start | Start REST function connector from MATLAB |
stop | Stop REST function connector from MATLAB |
changeToken | Change token of REST function connector |
changeCertificate | Change certificate of REST function connector |
reset | Restore properties of RESTFunctionConnector to default
values |
Examples
View RESTFunctionConnector
Properties in MATLAB
A RESTFunctionConnector
manages communication
between MATLAB and client applications.
Get connector conn
in your MATLAB application. The TokenExpirationDate
value indicates
that you obtained the connector on September 20, 2024.
conn = restFunctionConnector
conn = RESTFunctionConnector with properties: Port: 9920 LogLocation: "<mwPath>\restfcnconnector\logs" HostName: "" ClientAccessMode: local ServiceNames: 1x0 string RESTPersonalAccessToken: "AQIDBAUGBwgJCgsMDQ4PEBESExQVFhcYGRobHB0eHyA=" TokenExpirationDate: 20-Oct-2024 Certificate: "<mwPath>\restfcnconnector\publickey.pem" CertificateExpirationDate: [0×0 datetime] BaseURL: "" Status: notrunning
Update Token Using RESTFunctionConnector
Object
First, get a REST function connector.
conn = restFunctionConnector; conn.ClientAccessMode = remote;
Stop the existing connection.
stop(conn);
Generate a new personal access token, specifying its valid timespan as 45 days. The
TokenExpirationDate
value indicates that you made the change 45
days earlier, on October 20, 2023.
changeToken(conn,45); conn
conn = RESTFunctionConnector with properties: Port: 9920 LogLocation: "<mwPath>\restfcnconnector\logs" HostName: "" ClientAccessMode: remote ServiceNames: 1x0 string RESTPersonalAccessToken: "QADIABUGwBgJCgsMDQ4PEBESExQVFhcYGRobHB0eBcD=" TokenExpirationDate: 04-Dec-2023 Certificate: "<mwPath>\restfcnconnector\publickey.pem" CertificateExpirationDate: 20-Sep-2023 BaseUrl: "" Status: notrunning
More About
Pathname Displays <mwPath>
When displaying a pathname, MATLAB uses <mwPath>
to refer to the location of the
application folder used by MathWorks® applications. For example, refer to the LogLocation
property of a RESTFunctionConnector
object.
conn = restFunctionConnector
conn = RESTFunctionConnector with properties: Port: 9920 LogLocation: "<mwPath>\restfcnconnector\logs" HostName: "" ClientAccessMode: remote ServiceNames: 1x0 string RESTPersonalAccessToken: "AQIDBAUGBwgJCgsMDQ4PEBESExQVFhcYGRobHB0eHyA=" TokenExpirationDate: 19-Oct-2023 Certificate: "<mwPath>\restfcnconnector\publickey.pem" CertificateExpirationDate: 20-Sep-2023 BaseUrl: "" Status: notrunning
The pathname is platform specific, so <mwPath>
can represent these values:
On Windows®:
\%APPDATA%\MathWorks
or\%LOCALAPPDATA%\MathWorks
On Linux®:
$HOME/.MathWorks
On Mac:
/Users/$USERNAME/Library/Application Support/MathWorks
Version History
Introduced in R2024a
Commande MATLAB
Vous avez cliqué sur un lien qui correspond à cette commande MATLAB :
Pour exécuter la commande, saisissez-la dans la fenêtre de commande de MATLAB. Les navigateurs web ne supportent pas les commandes MATLAB.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)