I'm working on adding tracing to websockets in .net core. Using opentelemetry, how can we add a new span for each message communicated over that websocket connection?
Related
I have an ASP.net Core web API running the ASP.net Core Web Host.
In the ServiceCollection, I register a HostedService to run a worker that subscribes to a message bus.
Some messages come from web API. Some messages come from the message bus through the worker.
They all get written to a database.
Presently I'm having problems where when I write messages coming from the worker to the database I get System.ObjectDisposedException on my dependency injected data access Scoped service.
It feels like my worker is somehow using the HTTP request scopes for the DI injected services.
So, could this be caused by using a Hosted Service in the ASP.NET Core Web Host
Do not read messages in a ServiceHosted, you should read it seperately (maybe in a singleton scenario)
If you're reading messages from service-bus manually you should not have that problem otherwise you should not use scoped services for that. for example in RabbitMQ the best practice is to open a connection for each app
I am using signalR with ASP.NET Core 2.1 to send and receive messages from server-to-client or client-to-server even I also used streaming channel to send long message in chunks greater than 30kb from client to server.
But now I am wondering is it possible that I can make communication between server and client using voice or video?
I checked WebRTC is giving the solution for my requirement but as I am already using SignalR so I am looking for the solutions using SignalR for the websocket transport.
Adding answer to my old question as nobody added any response to it.
Yes, it is possible to use signalR core with WebRTC as a signaling server.
Here is the sample project that I created for .NET Core 3.1. Feel free to ask me question related to my approach.
I have created a tcp ip client and server as console application. And they are working fine using the netdatacontract serializer. Now I converted client console app as client library and want to consume this response from WCF service. I created this WCF service using nettcp binding. The problem I am facing is my response is always returned as null from client library, but the same client is working in console app without using this client in WCF service. Can somebody help me please?
I've followed the instructions from https://github.com/SignalR/SignalR/wiki/Hubs
entitled "Broadcasting over a Hub from outside of a Hub".
I got this method working from within an MVC Action in the same project. Requesting the Action sends the update to connected clients.
My problem is that I need to be able to send updates from another project, in particular a WCF Web Services project. My app has an API and a web component and when API users make calls that change things, these updates need to be pushed out to the Web clients via SignalR. And calling a web service with the same code as my Test Action doesn't work.
I also tried the same code inside an nunit unit test that didn't work either.
What do I need to do to make this same method described on the Wiki work for a WCF Project?
The easiest solution is probably to provide an API on your Web Application (use MVC or the new WebAPI) that broadcasts to all connected clients. Any other application (an NT Service, an NUnit test, ...) can call that API if it wants to send a message to the clients.
You can't expect SignalR to do anything if you aren't hosting a Hub either in a Web Application running under IIS, or another application hosting it directly.
If you need two-way communication from your separate application to your clients then simply make your application into a SignalR client too and have it communicate via the Web Application hosted SignalR to the clients and have it listen to messages from them too.
For example, here's how I have configured a complex Service + WebSite + Clients solution (ignore the purple for now):
The Live Web Server allows NT Services to connect and create SignalR Groups. NT Services send to those groups. Web browsers connect to a group and receive messages send to that group. In effect the middle box becomes a pubsubhub.
I cannot get exactly what you aim. But if I understood correctly you're trying to send some kind of notifications raised inside WCF services to SignalR clients.
If that's the case; I can suggest you my approach:
I have some WCF services and a SignalR hub in the same application server. IMHO, the best way to communicate WCF with SignalR hub is by using MSMQ.
When a notification occurs inside a WCF service, it puts the notification payload into MSMQ.
On the other end, SignalR hub listens the same queue. When a message put into the queue, it gets the content and broadcasts to the hub clients. Very easy and straightforward. No extra service/hub call at the server side.
SignalR hub can listen for new queue items by using System.Messaging.MessageQueue#ReceiveCompleted method. When this event raised, SignalR hub gets the queue item and broadcasts to its clients.
I have a problem that in JMeter I can setup server / port, but my application is hosting on IIS 7.5 and WCF service is a "Application" under specific web site. So the service endpoint is
http://localhost:8002/Some.Aplication/Some.Application.svc
WCF application is supporting tcp.net binding also and I should use it(tcp.net).
Ho can I set up JMeter for sending specific packet over tcp to this endpoint ?
Thanks.
You need to use TCP Sampler, and probably write a custom TCPClient class for it for easier handling of custom reads/writes.