简体   繁体   中英

Sending Message From Server to Js Client

I am trying to implement websockets in my Java j2ee servlet application. I am trying to send messages using the websockets. I have it working for multiple js clients and websocket server on java backend. Now, I also want to implement a way to send messages from java backend to the js client, without having to initiate anything from the js client itself. Is there anyway to achieve this?

There is no way for an HTTP 1 server to initiate a WebSocket connection to an HTTP client. The client must initiate it.

However, HTTP 2 offers the alternative of combining server-side events and document push requests; see Server-initiated requests .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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