简体   繁体   English

为什么使用strophe.js的XMPP客户端仍在使用包括flXHR.js?

[英]Why XMPP client using strophe.js still working with out including flXHR.js?

I am using ejabberd as XMPP server,one of our project need to have a xmpp web client,for that i am referring Professional "XMPP Programming with JavaScript and jQuery" by jake moffitt i was going through chapter 3 hello world application ,here in order to make xmpp web client using strophe i have to include creating java script file such as strophe.js,flXHR.js,and strophe.flxhr.js 我使用ejabberd作为XMPP服务器,我们的项目之一需要有一个xmpp web客户端,因为我指的是jake moffitt的专业“XMPP编程与JavaScript和jQuery”我正在通过第3章hello world应用程序,这里按顺序使用strophe制作xmpp web客户端我必须包括创建java脚本文件,如strophe.js,flXHR.js和strophe.flxhr.js

i have gone through example many time but failed to connect with the server, when i checked bosh connection using localhost:5280/http-bind it is working fine!!!!! 我已经经历了很多次的例子,但未能与服务器连接,当我使用localhost检查bosh连接时:5280 / http-bind它工作正常!!!!!

with try and error when i try to connect with xmpp server with removing flXHR.js ,it magically got connected to xmpp server!!!!! 当我尝试通过删除flXHR.js连接xmpp服务器时尝试和错误,它神奇地连接到xmpp服务器!!!!!

FLxhr.js is used for making cross domain call as per book" Flash has a strict security policy, but unlike JavaScript, it allows cross-domain requests to be sent to domains that permit such requests." FLxhr.js用于根据书籍进行跨域调用“Flash具有严格的安全策略,但与JavaScript不同,它允许跨域请求发送到允许此类请求的域。”

If i bypass above FLxhr.js i have to use a proxies 如果我绕过FLxhr.js,我必须使用代理

i am using apache tomcat as web-app server ,i haven't setup any proxies and not included FLxhr.js file in my html page ,but still xmpp client is able to communicate with server!! 我使用apache tomcat作为web-app服务器,我没有设置任何代理,也没有在我的html页面中包含FLxhr.js文件,但仍然xmpp客户端能够与服务器通信!

Can some one please explains me what is the reason behind this?? 有人可以解释一下这背后的原因是什么?

thanks in advance!! 提前致谢!!

It's likely that your XMPP server has CORS enabled, I know Openfire now supports this. 您的XMPP服务器可能已启用CORS,我知道Openfire现在支持此功能。 With CORS, strophe.js is able to make a cross origin request without needing the workaround provided by flash(FLxhr.js), and also works without any server side redirects. 使用CORS,strophe.js能够在不需要flash(FLxhr.js)提供的解决方法的情况下发出跨源请求,并且无需任何服务器端重定向即可运行。

Cross-Origin Resource Sharing 跨源资源共享

Cross Domain AJAX for XMPP HTTP-Binding Made Easy 跨域AJAX for XMPP HTTP-Binding变得简单

CORS Browser Support CORS浏览器支持

If you want to quickly check to see if your XMPP server has CORS enabled, you should be able to locate a crossdomain.xml file hosted on the root of your server. 如果要快速检查XMPP服务器是否启用了CORS,您应该能够找到托管在服务器根目录上的crossdomain.xml文件。

Example: 例:

I connect Strophe to my XMPP server using the address http://192.168.0.26:7070/http-bind/ . 我使用地址http://192.168.0.26:7070/http-bind/将Strophe连接到我的XMPP服务器。

Since I have CORS enabled, I can browse to http://192.168.0.26:7070/crossdomain.xml and the server will return an XML file. 由于我启用了CORS,我可以浏览到http://192.168.0.26:7070/crossdomain.xml ,服务器将返回一个XML文件。

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

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