1

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?

Michel Floyd
  • 18,793
  • 4
  • 24
  • 39
ijjo
  • 525
  • 9
  • 22

1 Answers1

2

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.

Michel Floyd
  • 18,793
  • 4
  • 24
  • 39
Peter Moskovits
  • 4,236
  • 1
  • 20
  • 15
  • thank you for pointing me in the right direction. i found that section in the config file and modified the allow-origin to * and it started working! little surprised this info wasn't in any of the other sections (like the intergating kaazing with web server) because it was critical to getting my website integrated properly with kaazing. – ijjo Nov 21 '11 at 04:19
  • Probably needless to say that adding a wildcard to your config file is OK while testing your environment. In production, however, you should have the strictest possible configuration. – Peter Moskovits Nov 21 '11 at 05:14