java - Websocket and cross-domain - Stack Overflow

Currently, I am developing two webapps : the core, developed in Java with Vert.x, receives data from a

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 puter. 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 ;) ):

  • For the core :
  • For the client :

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 puter. 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 ;) ):

  • For the core : http://pastebin./h2ZnBvQJ
  • For the client : http://pastebin./DR5BeABf
Share Improve this question edited Jun 8, 2014 at 11:47 guido 19.3k6 gold badges73 silver badges97 bronze badges asked Jun 4, 2014 at 7:19 user3699849user3699849
Add a ment  | 

1 Answer 1

Reset to default 0

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/wiki/WebSockets for an example of a handshake.

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745346644a4623580.html

相关推荐

  • java - Websocket and cross-domain - Stack Overflow

    Currently, I am developing two webapps : the core, developed in Java with Vert.x, receives data from a

    8小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信