Create Client Connection

The connection between a Python® client and a MATLAB® Production Server™ instance is encapsulated in a matlab.production_server.client.MWHttpClient object. You use the constructor to instantiate the connection between the client and the server.

The MWHttpClient() constructor has the following signature:

client.MWHttpClient(url[,timeout_ms=timeout])

The constructor has the following arguments:

  • url — URL of the server instance to which the client connects. The URL must contain the port number of the server instance.

    Note

    The URL contains only the host name and port information of the server instance.

  • timeout_ms — Amount of time, in milliseconds, that the client waits for a response before timing out.

    The default time-out interval is two minutes.

Note

The MWHttpClient object is not thread-safe. If you are developing a multithreaded application, create a new MWHttpClient object for each thread.

Create a Default Connection

To create a default connection, provide a value for the server instance URL. The timeout_ms argument has a default value, so you do not need to specify a time. This code sample shows how to connect to server instance on a host named mps_host using the default time-out of two minutes.

import matlab
from production_server import client 

my_client = client.MWHttpClient("http://mps_host:9910")

Configure the Connection Time Out

You specify the connection time out by providing a value for the timeout_ms argument. This code sample specifies a time-out of one minute.

import matlab
from production_server import client 

my_client = client.MWHttpClient("http://mps_host:9910",timeout_ms=60000)
Was this topic helpful?