最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

java - Websocket and cross-domain - Stack Overflow

programmeradmin2浏览0评论

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?

发布评论

评论列表(0)

  1. 暂无评论