-
Notifications
You must be signed in to change notification settings - Fork 679
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Unity] Bug: 运行puerts的nodejs http示例,localhost访问不到 #1745
Comments
|
如果是unity,你应该要在update那调用JsEnv.Tick |
十分感谢!这对我很有用!我会去仔细研究这个函数的含义,感谢您的解答! |
@chexiongsheng 我很遗憾的是,虽然nodejs在editor中好使了,但在我打包出的unity apk运行在手机上时,他依旧无法成功创建服务,我很确定我下载的puerts是最新的且backend为nodejs: |
editor可以,手机上应该就没问题。你看是不是场景没启动,脚本没启动,防火墙之类的问题。 |
前置阅读 | Pre-reading
Puer的版本 | Puer Version
2.0.5
Unity的版本 | Unity Version
2022.3.23
发生在哪个平台 | Platform
Editor(win)
错误信息 | Error Message
运行puerts的nodejs http示例,例如mjs:
const server = require('node:http').createServer((req, res) => {
res.writeHead(200, { 'Content-Type': 'text/html' });
res.end('
Hello, World!
This is a simple Node.js HTTP server using ES modules.
');});
const PORT = 9223;
server.listen(PORT, () => {
console.log(
Server is running at http://localhost:${PORT}
);});
或者是直接通过env.Eval调用:
const http = require('node:http');
http.createServer((req, res)=> { res.writeHead(200);res.end('helloworld') }).listen(9223);
在editor下运行,不会报错,netstat显示服务端口正在运行,但http get没有反应
另外,当尝试使用import http时,报错module not found,为什么require就能找到呢?用的应该是同一个node.dll吧
问题重现 | Bug reproduce
稳定复现,get不了服务的问题
The text was updated successfully, but these errors were encountered: