Question

i am using http-bind with openfire to enable BOSH and accessing that service using strophe and the issue is i am getting following error in chrome

here is the error in console

XMLHttpRequest cannot load http://127.0.0.1/http-bind. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access.

enter image description here

here is the request

enter image description here

i have enabled BOSH as follows in openfire

enter image description here

i have tried following to do in apache config file httpd.conf BUT NO EFFECT

<Proxy /http-bind>
        Order allow,deny
        Allow from all
</Proxy>

ProxyPass /http-bind http://127.0.0.1:7070/http-bind
ProxyPassReverse /http-bind http://127.0.0.1:7070/http-bind
Was it helpful?

Solution

The error No 'Access-Control-Allow-Origin' header is present on the requested resource indicates that you are making a Cross-domain (CORS) request and the necessary CORS headers are not available.

You are making a cross-domain request because the BOSH service (i.e. http-bind) is being served on a different port than your website.

I see in your HTTP Bind settings for OpenFire that you have enabled CORS. Perhaps you are using a Browser that doesn't support CORS? (Like IE9).

In any case, you can solve this for all browsers by instead of using CORS, reverse proxying the http-bind address to be on the same domain and port as from which the HTML is served.

This snippet in Apache will do that for you: (I'm assuming you're serving the site on port 80).

<VirtualHost *:80>
    ServerName localhost
    RewriteEngine On
    RewriteRule ^/http-bind(.*) http://localhost:7070/http-bind$1 [P,L]
</VirtualHost>

So you can then access the BOSH service (i.e. http-bind) on the same domain (and port) as the site itself.

For more info, see Converse.js documentation on this

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top