Can't use webread on nodejs local server in Matlab mobile

I am using nodejs with express framework and javascript code to create a local responsive server like this
const express = require('express');
const app = express();
app.listen(8080, '0.0.0.0', function() {
console.log("On port 8080");
});
app.get('/', (req, res) => {
console.log('someone asking');
res.send('Hello');
})
The server is operational when I access to 'http://(myIp):8080'by web browser. Also i use webread in Matlab to get data from node server (webwrite to send back data). It worked well in my laptop Matlab software. Not until i used that function in Matlab mobile or Matlab on web browser, it always got timeout, eventhough i set web timeout to inf like this
myUrl = 'http://(myIp):8080';
myOpt = weboptions('timeout', inf);
myRes = webread(myUrl, myOpt)
Error using webread (line 136)
The connection to URL 'http://(myIp):8080' timed out after 5.000 seconds. The reason is "Connection timed out after 5100 milliseconds". Perhaps the server is not responding or weboptions.Timeout needs to be set to a higher value.
webread in Matlab mobile still works with other urls that response data like 'https://requestserver.mathworks.com/employee'. Did i get wrong somewhere or is this an impossible task for any reasons? Somebody, please help me!

Réponses (1)

Yongjian Feng
Yongjian Feng le 24 Oct 2021
When you said "i used that function in Matlab mobile or Matlab on web browser", where do you run your server? You local laptop as well?
Matlab on web browser means matlab online?

5 commentaires

Trung Nghia Pham
Trung Nghia Pham le 25 Oct 2021
Modifié(e) : Trung Nghia Pham le 25 Oct 2021
My local server is run by Nodejs platform, and the function 'webread' i used in Matlab mobile or Matlab online, as you said, to get data from the server was completely failed.
The "local" server is running on your local laptop, right?
This won't work, the Matlab online won't be able to talk to your laptop.
Trung Nghia Pham
Trung Nghia Pham le 26 Oct 2021
Modifié(e) : Trung Nghia Pham le 26 Oct 2021
But they are on the same network ip. And if I use webread in Matlab software from my another laptop, it's still working fine.
You laptop (running nodejs) and your other laptop are basically within the same network. So it works. But matlab online is outside local network (school, company, or home).
Is there anything I can do to reach the goal, which is sending datas from matlab mobile to local server?

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by