Can't get MassTransit with MSMQ to work on IIS Express - c#

I have a .NET MVC 4 web app that uses MassTransit with MSMQ. We have several legacy apps that use MSMQ, so I'm constrained to that protocol. My client code in Application_Start() in my global.asax.cs file looks like this:
Bus.Initialize(sbc =>
{
sbc.UseMsmq(a => a.UseSubscriptionService("msmq://localhost/mt_subscriptions"));
sbc.ReceiveFrom("msmq://localhost/webconsole?tx=false&recoverable=false");
sbc.UseControlBus();
sbc.UseBinarySerializer();
});
I'm running this app on a Windows 8.1 developer box, and this call completes successfully & communications work as expected when I run it on IIS 8.5. However, when I run it on IIS Express 8.0, the call never completes and will eventually throw a timeout error. I found the following in the IIS Express FAQ:
Q: Does IIS Express support non-HTTP protocols such as net.tcp or MSMQ?
A: No. IIS Express only supports HTTP and HTTPS as its protocol.
Ok, fair enough, but I don't understand what the web server has to do with MSMQ (aside from using MSMQ over HTTP, which I am not attempting to do); I don't have any "msmq://" routes or anything like that. Doesn't MassTransit use MSMQ directly without going through the web server? And I can't believe that I'm the only developer out there who develops on IIS Express with MassTransit.
Any insights as to what is going on here? Thanks!

So I did finally figure this out, I thought I would post the answer to perhaps save someone else from banging their head against this particular wall. During startup, MassTransit looks to see if Windows Performance Counters are available. For some reason, checking for their existence when running on IIS Express results in a hung call. You can find an entire discussion thread on the subject here, it's also been an issue for SignalR and Windsor Castle developers: https://groups.google.com/forum/#!topic/masstransit-discuss/Pz7ttS7niGQ. As a result of the discussion, the MassTransit developers added a DisablePerformanceCounters() method to their API, and calling that method when creating the service bus fixed my problem.

Related

Possible problems with Owin SignalR hosted in IIS 10 Express or IIS 10?

this is my first questions on SO. Normaly I just wander the internet reading stuff until I can make up a solution.
So up until now we use HTTP Request and Response Model to communicate with Clients.
Using C# ASP.Net .Net Framework 4.0 hosted in IIS.
This way we are not able to forward information in real time to them from the server.
We would need to wait till the clients contact the server.
To solve this issue I think OWIN with SignalR V2 Middleware hosted in IIS would give us the ability to use Remote Procedure Calls, so whenever something happens that needs to be forwarded immediately to the Client, we can do so by calling that specific clients function or all clients.
For this of course the target Framework of the application needs to be .Net Framework 4.5 at least.
Now the problem I have is that in the Microsoft Documentation it says to use the IIS Express version, in order to enable the server to have more than 10 connections.
On the client side it would be no problem as ideally there would only be one connection at any given time.
But the Server should be able to have a whole lot more than just 10. As the Websocketconnections would stay open.
I am not an IIS expert, but why are there these limitations in the non Express version?
I would expect that one should be able to set the number of maximum connections despite the IIS version?
What are the gains of using IIS instead of self-hosting OWIN?
I would guess that I would need to implement some security features myself?
On my development PC a client Windows Service with SignalR V2 is able to communicate with an OWIN SignalR V2 hosted in IIS application.
At the moment I need to evaluate what needs to be considered to set this up on a server to ensure functionality.
I hope this all makes sense.
I am implementing Remote Procedure Calls in our Webservice, for real time communication with clients.
I read documentations about RPC, SignalR V2, OWIN and Katana.
At the moment I need to evaluate what needs to be considered to set this up on a server to ensure functionality.

Azure web app: Web sockets abort after 100 seconds

I'm writing a web socket application which I intend on hosting on the cloud using an Azure web app.
The web socket is implemented using a fairly standard piece of Owin Middleware and is fully functional for the first 100 seconds. After this time the websocket seems to enter the aborted state like clockwork.
[CLIENT][06/04/2018 11:27:21] WS client connected
[CLIENT][06/04/2018 11:29:01] WS client disconnected
Trying this on an IIS Express instance gives the same issue, although the delay seems to be 90 seconds rather than 100 (this is also consistent).
Running the same websocket as part of an Owin self-host app yields stability for over 25 minutes - so this definitely seems to be a problem caused by the hosting server.
On the azure web app hosting I've enabled web sockets, and also tried to enable the "Always On" feature in hopes that this would prevent the issue by preventing the server from going into a standby state - but this has not helped.
Are there any azure settings that I'm not aware of that could be tweaked such that these web sockets can stay open for longer periods of time?
Many thanks
Unfortunately, it seems that azure and IIS were both red herrings, the issue instead was an issue experienced with using the C# implementation of System.Net.Websockets.ClientWebSocket. The detail is brilliantly summarized at: .NET WebSockets forcibly closed despite keep-alive and activity on the connection
To others experiencing this issue, an effective (but not ideal) work around is to run the following once before creating a client web socket:
ServicePointManager.MaxServicePointIdleTime = int.MaxValue;

How to host a WCF service

I am trying to create a chat application in WCF.
I've created the client and the service on a localhost using httpBinding,
this is the service endpoint:
http://localhost:9999/ProductService
Now, I really don't know how to make the program run 'globaly' and not on a localhost.
Is there anyway to host the server on my pc? or run the application serverless using p2p communications?
Thanks anyway for your Time
You can set up at publicly accessible web server on your own computer, but it's definitely not recommended for any production purposes, unless you have a good understanding of this and have a internet-connection that allows for it, both technically and legally.
You should probably get external web hosting for this instead.
But if you really want to do this, you can install IIS to host the service.
As a side note, I don't think WCF is the optimal route to take for this anymore. Maybee you should check out SignalR and/or WebSockets instead. And ASP.NET Core WebAPI. It's not really anything wrong with WCF, but for new projects I wouldn't recommend it.

WCF self hosting and IIS

Does WCF self hosting, still uses IIS or some Virtual Server based on IIS.
Eg: After coding a very basic WCF host, it s possible to invoke an endpoint such as
http://localhost:9090/foo.svc
For example: invoking a WCF host via TCP, does that use IIS internally?
I m trying to avoid IIS due to another app i m using, which doenst work with IIS Threads. That s why asking. so i d like to manage my own AppDomain and threadpool rather than IIS.
Any recommendation?
Can i seperate hosting of WCF from IIS?
When you self-host, you are using not a shred of IIS at all. You don't need IIS on that machine - nothing.
WCF self-hosting will require the http.sys driver for its http-based communication - but that's all there is. There is absolutely no trace of IIS needed - none, zip, nada.
Self-hosting WCF also allows you to pick your own service addresses and use whatever suits your needs - there's no virtual directory and no *.svc file to be dealt with.
It depends on the bindings. if you do a BasicHttpBinding, then all the communication will be over HTTP.
As for hosting WCF, there is the test server that comes with Visual Studio that you can use (it runs as a service. It's called WcfSvcHost.exe), but I wouldn't recommend it for production. If you are just testing, then you could just launch the WCF in the Visual Studio debugger and use its address all you want (it will be http://localhost:1234/foo.svc in that case)
If you are looking for a production hosting, you can use WCF as a SOAP endpoint, and here there is a pretty good article over at The Code Project that talks about creating a service for self hosting

how to create a c# app to listen for xmls and reply in xml

I know that you can create web services in .net and have them run on iis. I'd like to make something that doesn't rely on iis as the webserver I'm using runs apache.
The eventual app should listen for incoming xml documents and repy in the form of an xml document, the client application will be running Javascript and sending xmls via http post requests. Is this something that SOAP handles?
All the guides and tutorials seem to follow the microsoft way, all hosted on servers running iis... is there a way around this?
As you can tell I'm quite confused as how to start.
I would strongly advise against implementing your own web service hosting platform - this really isn't a trivial thing to implement, especially if you want to be passing proper web service messages between your servers.
One option that would allow you to utilize WCF and Microsoft's baked in web service functionality is hosting WCF as a standalone service. In this model, you aren't using IIS to host the web service - you trade off some monitoring and logging functionality baked into IIS but it doesn't require IIS be installed.
Here's an article on WCF hosting options - http://msdn.microsoft.com/en-us/library/bb332338.aspx

Categories