1

我正在尝试在heroku上设置Weinre ,但我遇到了一些问题。

我设法构建了应用程序,只需使用带有 weinre npm 依赖项的 package.json 和如下所示的 Procfile

web: node_modules/weinre/weinre --httpPort $PORT

起初一切似乎都正常,客户端显示了 UI,JS 文件加载正常,但调试不起作用,并且没有客户端出现在服务器端。

在查看日志时,我意识到对于每个包含 /ws/target/* 或 /ws/client/* 的请求,我都会收到 404 错误

2012-05-31T22:37:53+00:00 heroku[router]: GET xxxx.herokuapp.com/target/target-script.js dyno=web.1 queue=0 wait=0ms service=10ms status=200 bytes=190900
2012-05-31T22:37:36+00:00 heroku[router]: GET xxxx.herokuapp.com/ws/target/t-3 dyno=web.1 queue=0 wait=0ms service=3ms status=404 bytes=9
2012-05-31T22:36:39+00:00 heroku[router]: POST xxxx.herokuapp.com/ws/client/c-1 dyno=web.1 queue=0 wait=0ms service=40ms status=404 bytes=9

此设置在本地运行没有问题。

我也尝试了 Procilfe--boundHost 0.0.0.0并得到了同样的错误。当我使用我的 heroku 应用程序域/子域作为主机时出现weinre: error running server: Error: listen EADDRNOTAVAIL错误

如果需要,您可以在github 存储库中查看源代码

https://github.com/felipesabino/weinre-heroku

编辑:这可能与 Heroku 不支持 WebSockets 有关: https ://devcenter.heroku.com/articles/http-routing#websockets

最奇怪的是,PhoneGap 的 weinre 调试页面也发生了同样的问题 http://debug.phonegap.com/

有谁知道如何解决这个问题?

4

3 回答 3

2

目前我已经在 Heroku 上运行,但我记得当我试图让它工作时,它是一场真正的噩梦。

这是使用2.0.0-pre-H0WVARLU-incubatingweinre 的,所以可能有点不同,但我必须做的是:

  • 修改 weinre 本身,我必须告诉 weinre 绑定到所有主机,我修改了cli.coffee文件并将其设置boundHost-all-默认值
  • 我赞扬了if remoteAddress签到,channelManager.coffee因为您进来的地址是通过代理重新映射的,并且从未匹配
  • 打开详细调试,虽然您实际上并不需要它来运行它,但它可以更容易地跟踪错误发生的位置(以及请求未路由的原因)

我的 Procfile 最终变得非常简单,因为我尝试尽可能地将 weinre 用作“本地”(请注意,repo包含weinre,它不是您正在做的模块):

web: node weinre

我留下任何端口更改由 Procfile 处理process.env.PORT,而不是从 Procfile 传入

基本上我发现 weinre 并不是为了在代理后面工作而设计的!

于 2012-06-06T05:56:46.080 回答
2

请参阅此拉取请求https://github.com/apache/incubator-cordova-weinre/pull/10

请注意,不需要其他修改,Procfile 可以设置选项(就像它应该的那样),并且 Weinre 被正确用作节点模块。

package.json(包含修复)

"dependencies" : {
    "weinre": "https://github.com/downloads/AppGyver/incubator-cordova-weinre/apache-cordova-weinre-2.0.0-pre-H77LBWIW-incubating-bin.tar.gz"
},

档案

web: node_modules/weinre/weinre --httpPort $PORT --boundHost -all- --debug true --verbose true
于 2012-09-17T14:07:46.330 回答
0
  • 修改 weinre 本身,我必须告诉 weinre 绑定到所有主机,我修改了 cli.coffee 文件并将 boundHost 设置为 -all- 作为默认值
  • 我推荐了 channelManager.coffee 中的 if remoteAddress 检查,因为您输入的地址是通过代理重新映射的,并且从未匹配

这两个提示对appfog也有很大帮助

你还需要

  • 将 weinre 重命名为 app.js
  • 需要本地咖啡脚本
  • 将 cli 分配给变量并直接执行 run
  • 扩展 cli.coffee -> 端口process.env.PORT
于 2012-11-15T15:30:10.383 回答