Can't use webread on nodejs local server in Matlab mobile
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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!
0 comentarios
Respuestas (1)
Yongjian Feng
el 24 de Oct. de 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 comentarios
Yongjian Feng
el 27 de Oct. de 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).
Ver también
Categorías
Más información sobre Introduction to Installation and Licensing en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!