How are web push messages delivered?

眉间皱痕 提交于 2019-12-24 16:32:53

问题


I try to set up push messages for a web page. While I understand the front-end part (the Push API) and have a working localhost demo app, I just don't get how a server can push a message to the browser.

How are the packages from the push service routed to the client? The client has no domain name and usually no fixed IP address, so how is this possible?

I've read Google's guide to Web Push Libraries and parts of RFC 8030, but if they have the answer to this question, it eluded me.


回答1:


Your application server makes a POST request using the browser endpoint as the URL.

The browser endpoint is something like: https://updates.push.services.mozilla.com/A_VERY_LONG_TOKEN_123. That means that the POST request is sent to a web service owned by the browser manufacturer (e.g. Mozilla autopush for Firefox).

Then the browser push service is responsible for the delivery of the message to the browser. It's the client that creates a persistent connection with the browser push service. Also consider that once the TCP connection is established you get a full duplex / bidirectional channel (the server can send messages without a prior request from the client).

See also this introduction about web push.



来源:https://stackoverflow.com/questions/48683770/how-are-web-push-messages-delivered

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!