Can someone tell me if service workers (https://developers.google.com/web/fundamentals/primers/service-workers/) support server sent events (SSE)?
As per the service worker specification's issue tracker, service workers should be able to intercept EventSource.
That being said, I've never seen an example of a service worker that did anything meaningful with server-sent events.
Related
I have an application running Laravel 6.1. There are clients which connect to it via laravel websockets and listen for events. I have an external service which sends post requests to this server which will then raise an event, and the websocket clients see it. I am in the dev stage, and it's not been deployed yet, this is what I'm currently researching. I use Docker, so there's an nginx container, a php container, and a Mysql container(in production, the containers will use RDS though)
This works fine in development, but the plan is to deploy in ECS, with Elastic Beanstalk, as it enables multiple containers per EC2 instance. I was planning on having these instances auto scale with a load balancer, so my question is how can I make the incoming events be raised and visible on all the servers? For example, the post request may hit one instance and the clients connected to that instance would see that the event was raised, but the clients connected to another instance will not see the raised event. Is this accurate? I'd imagine the events will have to be sent to some kind of "queue" which is monitored by all instances, but not sure how to implement that with Laravel or if there's a simpler faster way.
Based on the comments.
The proposed solution involves the use of sns instead of the SQS.
The reason is that sns allows delivery of messages to multiple recipients at the same time. In contrast, SQS is designed for one delivery of messages to only one recipient, unless used in fan out architecture.
I am facing a problem with masstransit. I want to use SQS and one queue only. I want masstransit to always send the messages to that queue and receive them on a specific endpoint. (So not publishing).
The sending to the queue works but for some reason I'm having problems receiving messages. The documentation examples do not work for me when connecting a consumer to an endpoint.. It complains about SNS (which I am not using)
Does anyone have a simple example?
Ok, so I found out that if you want to send messages to a queue, than SQS should be sufficient in combination with Masstransit. But when you want to recieve those messages, then Masstransit expects credentials that allow the creation of SNS topics.
I thought I had more say in what queues Masstransit will use for communication. But when you use Masstransit with amazon it will create it's own queues and SNS topics based on it's needs.
So when using Masstransit, like i did in my case. Give it AWS IAM user credentials that have the proper permissions to create SQS queues and SNS topics.
I have a scenario where a request is sent to a service via my client now the response comes inside a message queue in azure, How can I poll the queue at client end and update the view when the response comes say I have to update a label when data is recieved in the queue.
Azure has two types of queues - Azure Queue and Service Bus Queue. Although in theory you can access them from client side (I assume JavaScript) because CORS has been introduced some time ago (Not sure about CORS support for ServiceBusQueue), this might not be the best option.
Problems you might face:
Lot's of clients trying to process messages (locking and releasing), Azure Queue does not support sessions so you would have to either create queue per client or use Service Bus Queue (as I said earlier not sure about CORS) with sessions
What should happen when your client is not online anymore? Does the message stays in the queue? Till when? Expiration?
Different approach
You can do message processing on the server and only notify user about the change using SinglalR. This gives you much better flexibility (one message can trigger notification for many users etc).
SignalR Scaleout with Azure Service Bus
Using SignalR with Azure Table Storage - What architecture?
I am working on azure MVC4 application, i need to read messages from servicebus then update online users through IIS(by SignalR). I want to run some worker role type of process within the web role. Looking for best practices to deal with servicebus in web role itself.
To run the "worker role" inside the Web Role, you just need to implement RoleEntryPoint in your Web Project, just like you do in your Worker roles.
Just remember that this "background" process (WaIISHost.exe) runs in total isolation than your Web Application process (w3wp.exe). Although this article is very old, it still represents very clearly what process do run in your Web Roles.
You could host your SignalR in the "worker role", not the IIS. And pass messages from the web worker to the service bus, and read them from the worker process.
I think that the best solution is to work with a worker role with Service Bus, you can try the worker role with service bus queue.
you can get the required message from the web, send it through the service bus queue to the worker role, and then do the required process.
After that you can send the result back to the webrole whether by using the queue or the service queue backward.
you can check this link, I think he is doing something a little bit similar http://middlewareinthecloud.com/2012/06/23/azureservice-bus-queues-in-worker-roles/
and this is the MSDN URL for the Worker Role With Service Bus Queue
http://msdn.microsoft.com/en-us/library/windowsazure/jj149831.aspx
I have a WCF service method which takes more than two hours to execute (runs some reports). how can I make sure that it doesn't timeout regardless of the time it takes? I think there are many timeout settings in WCF config, I am not sure which one is relevant for me. for ASMX webservices, there was an option to specify infinite timeout setting, is there a similar one for WCF?. also do I need to alter any IIS settings for this (WCF servcie is hosted in IIS), like recycling of worker processes, idle timeouts etc?
This is an abuse of web services. Don't do this.
Instead, have the web service kick off the long-running operation, running in a separate process. If the clients need to know when the reports are done, then have the "separate process" keep track of the report creation and have it note when the reports are finished. The client can call a web service to check that status.
You really don't want to be depending on an HTTP connection remaining open for hours. It's a network. Things happen on networks. Bad things.
Have you considered using callbacks? Your client sends a request and then waits for a notification from the server for when it is done? This would probably require a change in the client, but in that way, your service can "rattle the chain" and tell the client when the report is finished.
help: http://idunno.org/archive/2008/05/29/wcf-callbacks-a-beginners-guide.aspx
WCF timeouts:
http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/84551e45-19a2-4d0d-bcc0-516a4041943d/
You should also consider the timeouts on the client side, as well. (binding.OpenTimeout, ReceiveTimeout, CloseTimeout etc.)
Another option would be to host the WCF in a Windows Service, which could simplify your situation, as it removes IIS from the equation:
http://msdn.microsoft.com/en-us/library/ms733069.aspx
Or, what about using a one way WCF call? That way, the call will return to the client ASAP after sending the request.
Need sample fire and forget async call to WCF service
Consider creating a WCF workflow service (using WF) instead. These are specifically designed to handle long-running processes, especially if you use persistence.