gpt4 book ai didi

dart - Dart 中的 net::ERR_UNSAFE_PORT

转载 作者:行者123 更新时间:2023-12-03 02:47:17 24 4
gpt4 key购买 nike

我正在使用 notepad++ 编写服务器端 dart 代码,我已经使用 dart 编辑器在服务器端 dart 代码中取得了成功。但是我同样认为我在使用notepad++的地方做了一个错误,因为浏览器中的 dart 中的 net::ERR_UNSAFE_PORT 完成了由命令提示符初始化的 Dart 服务器端,当我尝试访问 172....190 时,Bowser(dartium) 说上面那个错误!!!

服务器端代码

main() {
HttpServer.bind("172...", 4045).then((server) {
server.listen((res) {
res.response.headers.add("Access-Control-Allow-Origin", "172.25.10.181");
res.response.headers
.add("Access-Control-Allow-Methods", "POST,GET,DELETE,PUT,OPTIONS");
res.response.headers.add('Access-Control-Allow-Headers',
'Origin, X-Requested-With, Content-Type, Accept,application/x-www-form-urlencoded');
print('I am writing server side code');
});
});
}

客户端代码
req = new HttpRequest();

req.open('get', 'http://172...:4045');

req.send(data);

req.onReadyStateChange.listen((_) {
if (req.readyState == HttpRequest.DONE &&
(req.status == 200 || req.status == 0)) {
print(req.responseText);
}
});

最佳答案

这是处理此问题的最佳方法。

There some ports are reserved for specific protocols like 80 for HTTPand 22 for SSH etc. If you use that port for another kind of protocolyou will face this error. In my case, I'm using 6000 port for mybackend API server which was resolved. I just simply move 6000 port to7789 all stuff working as expected. Here are the list ports forspecific protocols that you may not violate. You need to use port other then this for your specific work.

关于dart - Dart 中的 net::ERR_UNSAFE_PORT,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35502345/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com