I keep getting the error trying to integrate Kaazing jms version with my .net website and activemq message broker:

Unable to post message to http://www.xgateway.com:8001. Recipient has origin http://www.x.com.

When I try to build a javascript client that is hosted by my Asp .NET website trying to connect to kaazing gateway.

I know I have everything setup ok, because i can go to www.xgateway.com:8001 and i can browse all the documentation and run the demos. I have run the stock ticker demo and watch it work perfectly. so all setup seems OK.

Now the problem is, I also have my asp .net website hosted on IIS 7 on the same machine. i'm trying to build javascript clients hosted on my .net website (port 80) that connect with the kaazing gateway. But I keep getting the above cross origin error.

In my client I am referencing StompJms.js as instructed. I have activemq setup up properly and working as well as the message broker. All demos working prove everything is setup properly.

i have also taken these steps following the instructions in the documentation:


Copy the file GATEWAY_HOME/lib/client/javascript/PostMessageBridge.html and serve it from the source origin web server (http://www.example.com); for example at http://www.example.com/bridge/PostMessageBridge.html. Note: You must ensure that the file PostMessageBridge.html is hosted on the same origin (same scheme, host, and port) as the web server.

Add the following tags (shown in lines 2 and 3) to the section of your main application page:

<head>
<meta name="kaazing:postMessageBridgeURL"
      content="http://www.x.com/PostMessageBridge.html" >
.
.
.
</head>

but still get the error. What else am i missing?

1

There are 1 best solutions below

2
On BEST ANSWER

Since the port numbers used by your .NET app and your kaazing websocket gateway are different, these are considered to be separate sites. Therefore, you'll need to specify cross-site-constraint for your service.

Here's a sample snippet you'll need to add to your gateway-config.xml:

<service>
  <accept>ws://localhost:8001/remoteService</accept>
  <connect>tcp://localhost:61613</connect>

  <type>stomp.proxy</type>

  <auth-constraint>
    <require-role>AUTHORIZED</require-role>
  </auth-constraint>

  <cross-site-constraint>
    <allow-origin>http://localhost:8000</allow-origin>
  </cross-site-constraint>
</service>

And here you find detailed documentation on the topic.