简体   繁体   English

一个域作为服务器,一个域作为客户端的跨域 Websocket。 有可能吗?

[英]Cross domain Websockets with one domain as the server and one as the client. Is it possible?

Hey guys just a theoretical question.嘿伙计们只是一个理论问题。 I have been using ratchet php websockets and have figured out that you can send cross domain requests between two different websites.我一直在使用棘轮 php websockets 并发现您可以在两个不同的网站之间发送跨域请求。 I have successfully been able to pass POSTs and SESSION variables across domains when switching pages.在切换页面时,我已经成功地能够跨域传递 POST 和 SESSION 变量。

Now my problem is this.现在我的问题是这个。 My current webhost isnt supporting websockets because its a shared webhost.我当前的虚拟主机不支持 websockets,因为它是一个共享的虚拟主机。 I have managed to get a cloud with amazon web services and host a chatroom im building on there, as well as log into it from my original webhost.我设法获得了一个带有亚马逊网络服务的云,并在那里托管了一个聊天室,并从我原来的网络主机登录。

But I'm working on a social network now and I dont want to pay through the roof for a VPS just to use the websocket feature.但是我现在在一个社​​交网络上工作,我不想为了使用 websocket 功能而通过屋顶购买 VPS。 So I figured if I wanted to build it in the meantime, maybe host the websocket server on the external cloud.所以我想如果我想同时构建它,也许在外部云上托管 websocket 服务器。

If I were to say, have a javascript client on my shared hosting website, but hosted the websocket server on the external cloud, would it be possible to send websockets to and from the external cloud server with the chat client on my website?如果我要说,在我的共享托管网站上有一个 javascript 客户端,但在外部云上托管了 websocket 服务器,是否可以使用我网站上的聊天客户端向外部云服务器发送 websockets? Do I have to do something special like I did with CORS to include headers and stuff?我是否必须像使用 CORS 那样做一些特殊的事情来包含标题和内容?

The kind of things I want to do includes: Facebook style private instant messaging, comments and posts updated live, live notifications, newsfeed, etc.我想做的事情包括:Facebook 风格的私人即时消息、实时更新的评论和帖子、实时通知、新闻源等。

Thanks :)谢谢:)

Yeah you can.是的,你可以。 See the link bellow : WebSocket请参阅下面的链接: WebSocket

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM