'Websocket and cross-domain

Currently, I am developing two webapps :

  • the core, developed in Java with Vert.x, receives data from a lot of other apps and sends it to client)
  • the client, developed in PHP/JS, display data from the core.

The client isn't on the same domain as my core for the production phase.

Since my development period, the two webapps are hosted in the same computer. I used "ws:\\localhost:9090" to connect my client to my core and I had no problem to transfer data.

But, today, I try to replace localhost with my IP Address and, it didn't work :s

I think that it's because the client isn't in the same domain as the core. But I don't know how I can correct this problem ?

Do you have any idea ?

Thanks !

Code example (based on my code but not my code ;) ):



Solution 1:[1]

Yes, Websocket can do cross-domain, but you will need to have a handshake in order to get this going. You might want to take a look at: http://en.wikipedia.org/wiki/WebSockets for an example of a handshake.

Also related and maybe duplicate: Web sockets make ajax/CORS obsolete?

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Community