Cloudflare Workers - Websocket Send Message to Client - websocket

In cloudflare workers we can create websockets as mentioned this blog post https://blog.cloudflare.com/introducing-websockets-in-workers/ but I tried to send message back to browser from server to specific client, I couldn't. I wonder how we can make something like that https://stackoverflow.com/a/17223609/9532712 with cloudflare workers.

You'll need to use a Durable Object: https://developers.cloudflare.com/workers/learning/using-durable-objects#websockets-in-durable-objects

Related

How to send spring-graphql client subscription ping messages

I'm using the spring framework's spring-graphql library to create a graphql client, as per the docs. When connecting to the server using a websocket for subscriptions, everything works fine for 5 minutes but then the websocket times out and disconnects. It turns out the server requires the client to send a ping message to keep the websocket alive. This is a graphql ping message as specified in the graphql-ws protocol
I've checked in the docs and had a dig around in the code but can't see any way to send this ping message via the spring graphql client. Apollo client has similar functionality to what I'm after via a "keepalive" option in the graplq-ws ClientOptions. Is there any equivalent I can use via spring or alternative way to solve this?
I couldn't find any way to do this so raised an issue on github, and subsequently a PR with some changes to add basic support for sending pings.
See https://github.com/spring-projects/spring-graphql/pull/608
and https://github.com/spring-projects/spring-graphql/issues/605

How to establish a websocket connection from a Twilio webhook?

I am trying to create a chat messaging application, which has text functionality. Right now, when a user sends an SMS message from their phone to a Twilio service number, there is a Twilio webhook which redirects to an endpoint in my backend server: sending HTTP POST request.
However, since it is a chat messaging application, I need the Twilio webhook to establish a Websocket connection (upgrading over HTTP) to my backend server, so that it can send websocket events back to my client.
Is there a way to establish a websocket connection using Twilio webhooks, or even Twilio functions? I can't find any resources online to solve this issue.
I tried Twilio Webhooks, and Twilio Functions, it hasn't worked so far.
WebSockets won't help you in this situation, as the webhook timeout limit is 15 seconds. This means you either need to return a TwiML response within 15 seconds or the request will fail.
It sounds like you want to build a stateful WebSocket connection instead of the stateless API callback. To achieve a stateful session, you either need to handle the state management over multiple incoming messages on your own, or you can use a Studio Flow which comes with state management baked in.

How to use websocket client in laravel backend

I have one api for stock trade.
this is the url for websocket communication with api server.
https://kite.trade/docs/connect/v3/websocket/
I've read about websocket for laravel, but almost are the content about sending socket request from client to server.
If then, in my case, I have to turn on browser all day long to get live market quote.
I want to make it possible to get live market data without turn on browser.
Till my understanding is, in node.js, using socket.io client, it is possible to send websocket request from server to socket server.
But in laravel, I could not find way.
If anyone has experience, please help me.
Thanks.

Is it necessary to use worker when send mail via mailgun http api?

I follow the laravel document to implement the mailgun service to send emails.
It is working quite well, but when my project starts growing large, I am considering some performance improvement.
When I look into the laravel queues, and its example is about using it for sending emails.
And here comes to my question,
When I use mailgun http api to send emails, is it going to improve server performance if I also put the request on queues?

grpc unsolicited message from server?

is it possible to create server based unsolicited "events", "messages"
(e.g. message that is NOT a reply to a client's request, but generated
on behalf of the server) in gRPC?
[Tried googling for it, but couldn't find any relevant answer, mind me]
Thanks,
If you want the server to initiate the connection from the server and send a message with no prior interaction from the client, then no, you can't do that with gRPC.
However, this fits perfectly into the "subscriber" pattern that gRPC is intended to support: the client opens a server-streaming request (possibly indicating which messages or events they would like to receive), then the server responds with each message or event as it appears.

Resources