简体   繁体   English

我如何将xmpp服务器集成到节点js应用程序中?

[英]How I can integrate an xmpp server into a node js app?

I'm trying to combine 3 node js servers in one. 我正在尝试将3个节点js服务器合二为一。

  • In first server I have app server. 在第一台服务器我有app服务器。
  • In the second one I have node-xmpp-server , 在第二个我有node-xmpp-server,
  • and in the last one node-xmpp-bosh server. 并在最后一个node-xmpp-bosh服务器中。

I want to integrate the last two server in application server.How can I do this?I've tried with express.vhost but I have received an error 我想在应用服务器中集成最后两个服务器。我怎么能这样做?我尝试过express.vhost但是我收到了一个错误

like this : most middleware like vhost is no longer bundled with express and most be installed separately. 像这样:像vhost这样的大多数中间件不再与express捆绑在一起,而且大多数都是单独安装的。

Thanks for any help! 谢谢你的帮助!

After comment below explaining that you want all 'apps' to start at the same time, I suggest that you start up all the apps using a single 'bootstrap' file passing through the ports that you want to listen on. 在下面的评论中解释您希望所有“应用程序”同时启动之后,我建议您使用单个“引导程序”文件启动所有应用程序,这些文件通过您要侦听的端口。 See this github repo for a very simple example that starts up two express apps from a single file index.js by requiring in the individual files that do app-specific configuration. 有关一个非常简单的示例,请参阅此github repo ,该示例通过在执行特定于应用程序的配置的单个文件中要求从单个文件index.js启动两个Express应用程序。

You can attach anything you want to the individual apps module.exports that can allow you to control them all as a group from code in the parent bootstrap file. 您可以将所需的任何内容附加到单个apps module.exports ,这些内容可以允许您从父引导程序文件中的代码中将它们全部作为一个组进行控制。


For those looking for a solution to the error reported by the asker, the below details how to resolve the error reported; 对于那些寻求问题报告的错误解决方案的人,下面详细说明了如何解决报告的错误; but doesn't solve the asker's problem 但并没有解决提问者的问题

As per the documentation on the express 3.x to 4.x changes and the answer to this question (though the middleware is different) now that vhost is no longer bundled with express it must be require d and used separately - it doesn't register itself on the express instance you're using, so you can't use the express.vhost method anymore. 根据快速3.x到4.x更改文档这个问题的答案(尽管中间件不同)现在vhost不再与express捆绑在一起它必须require d并单独使用 - 它不会在您正在使用的express实例上注册自己,因此您不能再使用express.vhost方法。

From here , these are the relevant lines: 这里开始 ,这些是相关的:

var vhost = require('vhost')

//...

// add vhost routing to main app for mail
app.use(vhost('mail.example.com', mailapp))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM