MATLAB TCP Server and Python Proxy Server for OPCloud

A MATLAB TCP server and a Python FastAPI proxy to run MATLAB functions remotely. Supports HTTP requests and FastAPI routing.

You are now following this Submission

MATLAB TCP Server and Python Proxy Server for OPCloud
This repository provides two methods to serve MATLAB functions remotely:
1. A TCP-based MATLAB server using Java sockets.
2. A Python proxy server using FastAPI to communicate with MATLAB.
Method 1: MATLAB TCP Server
This method runs a TCP server in MATLAB to execute functions via HTTP-like requests.
Running the MATLAB TCP Server
Start the server in MATLAB on port 4000:
serve(4000);
The server will start and wait for incoming connections.
Example API Call
Call MATLAB functions remotely using an HTTP request:
Example Function (functions/displacement.m)
function s = displacement(v_init, v_final, time)
s = (v_init + v_final)/2 * time;
end
Example Request (Browser or OPCloud)
http://localhost:4000/displacement?v_init=1&v_final=5&time=2
Expected Response
6
Stopping the Server
Close the figure window to shut down the server.
Requirements
MATLAB 2020 or later
Java (included with MATLAB)
Method 2: Python Proxy Server
This method runs a FastAPI-based proxy server in Python, which forwards requests to MATLAB.
Installing Dependencies
Ensure you have Python installed, then install the required dependencies:
pip install -r requirements.txt
Running the Python Proxy Server
Start the FastAPI server on port 4000:
fastapi run app.py --port 4000
Making API Calls
Call MATLAB functions through HTTP requests:
http://localhost:4000/displacement?v_init=1&v_final=5&time=2
Expected Response
6
Stopping the Server
Stop the FastAPI server with CTRL+C.
Requirements
Python 3.8 or later
MATLAB Engine API for Python (installed automatically via requirements.txt)

Cite As

Joy (2026). MATLAB TCP Server and Python Proxy Server for OPCloud (https://www.mathworks.com/matlabcentral/fileexchange/180232-matlab-tcp-server-and-python-proxy-server-for-opcloud), MATLAB Central File Exchange. Retrieved .

Tags

Add Tags

Add the first tag.

General Information

MATLAB Release Compatibility

  • Compatible with R2007b and later releases

Platform Compatibility

  • Windows
  • macOS
  • Linux
Version Published Release Notes Action
1.0.0