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

2 Ansichten (letzte 30 Tage)
Trung Nghia Pham
Trung Nghia Pham am 24 Okt. 2021
Kommentiert: Trung Nghia Pham am 30 Okt. 2021
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!

Antworten (1)

Yongjian Feng
Yongjian Feng am 24 Okt. 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 Kommentare
Yongjian Feng
Yongjian Feng am 27 Okt. 2021
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).
Trung Nghia Pham
Trung Nghia Pham am 30 Okt. 2021
Is there anything I can do to reach the goal, which is sending datas from matlab mobile to local server?

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Introduction to Installation and Licensing finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by