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

2 ビュー (過去 30 日間)
Trung Nghia Pham
Trung Nghia Pham 2021 年 10 月 24 日
コメント済み: Trung Nghia Pham 2021 年 10 月 30 日
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!

回答 (1 件)

Yongjian Feng
Yongjian Feng 2021 年 10 月 24 日
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 件のコメント
Yongjian Feng
Yongjian Feng 2021 年 10 月 27 日
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 2021 年 10 月 30 日
Is there anything I can do to reach the goal, which is sending datas from matlab mobile to local server?

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeIntroduction to Installation and Licensing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by