I recently found a .NET tutorial that showed me how to make a simple chat application in Visual studio using the .NET library, signalr.
I have created the application and made a few moderations including some AES encryption. I have then hosted it on Windows Azure as a website.
The chat application works and has been tested, but I don't know how to view the messages sent from one user to the other.
Can someone tell me where I can find these message streams?
Thanks
All messages will go through the SignalR Hub, so you could either use breakpoints/debugging to see what is send (if you are running in your development environment). Otherwise you could use tracing in the Hub to see the messages.
There is a extension to glimpse that you might use (I haven't tested it though): http://www.nuget.org/packages/Glimpse.SignalR
You can get some performance counters using the tools provided by Microsoft.
For what I know there is no way to get all messages send or received from the server. When you need to analyze the communication of specific clients, try to use Wireshark or Microsoft Network Monitor.
You could also write your own message logger that writes them to file.
You can use common methods as Trace.WriteLine to write info to the default listener. Then use a listener to write to file / database.
This source may be useful when learning to analyze messages from a webserver.
Fiddler is the best tool for monitoring web traffic. It's stupid easy to use and has a lot of extended features to help debug server/client applications. Take a look at this page which includes a brief description of using Fiddler with signalr.
Good luck!
Related
There is a program which sends image files in binary by using WebClient.UploadFile(someUri, "STOR", filename). I can't change that program, but I need to build a program to receive the file. I don't want to implement a full FTP server, so what should I be looking at to create the bare minimum logic in C# to receive the file? A bonus would be a solution that uses features present in .NET 3.5 or 4
I don't really know where to start, so any tip is appreciated. Thanks.
It sounds like you'll need to provide not an FTP server, but an HTTP server (aka a web server). From a little quick Googling, it looks like there's a library for embedding a simple web server into a .net application named Nancy that a lot of people seem to have good results with: Embedded C# web server?
Of course, this would be the quick and dirty way. Probably a better long-term approach would be to create a normal ASP.Net website to receive the images, hosted on a normal IIS web server. But if you have no experience in web development, that might be biting off a lot.
Thank you for the suggestions, but through more digging around I found out how to implement what I need. This is a very simple ftp server done in python using sockets. I was able to easily replicate this in C# using sockets again and I have adapted it to be able to authenticate a user of my choosing and write the received files to the disk.
The situation is: we've got a number of working application instances, developed on C#. We want them to log in one place (that could be a file). As far as I know log4net and NLog can send logs via TCP. The problem is - how to listen to these logs and store it?
Is there any working solution to collect these logs?
In log4Net you shoul configure appender, here official documentation see RemotingAppender
For the listen TCP you should use TcpListener like in this resource, there are exist some clients for log4net like this
In NLog you might consider the Database target. NLog has some other targets you might consider, including the LogReceiverService, which sends logging messages to a WCF Service or Web Service, where they can be logged to any of the NLog targets, including to a file.
In log4Net you might consider the AdoNetAppender. Configuration examples here.
I will note that, in the past, I implemented a WCF-based LoggingService (which is ultimately similar to NLog's LogReceiverService), which worked well for me.
It is better to use Application insights feature provided by MS. it can be used any language not just Microsoft languages. Application insights is divided into 2 parts. SDk for instrumenting telemetry(logs data) and visualizing these logs in azure dash boards. SDK is opensource and you need to pay for azure visualization tools. if you don't want to pay then use Application insgists in your code and send these logs to elastic stack which is open source
the best architecture
MS Application Insights -- for instrumenting logs
Apache Kafka -- acts as a pipeline and as temporary stoarge, send your logs to kafka
logstash-- a filter with which you can filter log
elasticsearch -- a no sql db to where the filtered data stored
kibana -- dash boards which pulls data from elastic and give vizualisations.
also you can link spark to kafka output to trigger alerts in form of emails, text messages.
Overview
C# File - Users PC
PHP Server - Hosts Webpages for application
Server and Users PC on local network
I have a c# file that reads weight from a USB scale. How would I trigger this file to run so it feeds into my program. The problem is I am using PHP to host our webpage/application so its not running client side and the scale is not hooked up to the server but to the clients PC.
The C# script would have to be on the clients in order to read the scale so how would I trigger this to happen?
Is this even possible and if not what would be a better way?
Important Edit
I was able to run the Scale Script (C#) when I wanted by having PHP and C# use TCP sockets.
The C# would listen for PHP to send something and when it did it would read the scale and send this information back to PHP becuase PHP was listening for a response. Mixed in with a little Ajax and it updates in the web browser.
Gave Chris Credit because he was the most helpful with answering my questions
It sounds like what you really want is for the client application to submit the data to the website itself, and the most suitable approach is probably to expose a web service from your server.
This service should accept weight data, along with some sort of customer key or whatever, to correlate the records correctly on the server side. I've never created a web service in PHP personally, so I can't give any advice on the implementation of that, but it is fairly trivial to hook a C# client app up to a web service once you've exposed its metadata (assuming you use SOAP).
you can't start C# application from a web page in a way that'll work in every browser every time. BUT, you can have some workarounds:
Use ActiveX component that read the data in the client and upload it to the server. the biggest cons is that it'll only work in Internet Explorer
use Silverlight client application that runs on elevated mode (v4) and upload the data to your server.
refer your clients to download application (the C# application you wrote about) and run it - this application will upload the data to your server.
hope this helps.
C# isn't a scripting language, it's a language that compiles into executable binaries or libraries. You won't be able to execute C# code on the client's computer via a website because C# code needs to be compiled before it can run.
Presumably what you really want is for your compiled C# binary to be executed on the client's machine via your website. You won't be able to easily do that. There are a lot of security measures in place to prevent browsers from running programs on your computer. There may be ways to hack around these security measures by using plugins (such as ActiveX), but it's not something that will be a one-liner.
Edit: I think you need to step back and think about what you're trying to do in a broad sense. You're trying to create a website that can read information from a user's USB port. This is the type of thing that browsers are designed to prevent, and for good reason. I wouldn't want random websites to be able to access peripheral hardware without my explicit permission. If you want this website to function the way you're expecting, you're going to have to seriously think about the security implications. You'll need some kind of client-side code (ActiveX, Silverlight, ...), and the user will need to explicitly give permission to for this all to happen. It won't be easy, and it won't be automatic. And I'm damn glad that's true.
I want to develop a game in real time.
updated for all users on a picture every second. But I have no idea how to do, Is there something similar, i can use the sample code?
I'll use C# and Asp.NET
Note: Sorry for my bad english.
Try using SignalR, from what I can tell from your question, this would work well for doing game updates.
https://github.com/SignalR/SignalR
https://github.com/SignalR/SignalR/wiki/Getting-Started
If latency really matters then you should be looking at a WebSocket solution and not one introduces the overhead of requiring HTTP Requests. WebSockets support bi-directional communication between a client and server over a single connection which keeps latency to an absolute minimum. Other HTTP-based solutions, including EventSource, mean that data coming from the server to the client can be sent with low latency but messages from the server to the client have to be made by establishing a new HTTP request which introduces latency.
So, this means that ASP.NET is not a good choice for a truly realtime game at the moment.
What are the alternatives?
If you want to stay in the .NET world then I'd consider looking at XSockets or SuperWebSocket.
If you would consider other technology solutions then I've compiled a list of realtime web technology solutions. Again, when making a choice I'd favour solutions that have WebSocket support.
If you want to keep close to the Microsoft stack you could look at socket.io on Windows Azure. See Running Socket.io on Windows Azure Web and Worker Roles
If you would consider Node and a hosted service then the Pusher Pipe might be of interest for you.
From version 1.0 beta, the version just recently published on Nuget there is some changes regarding the XSockets Server (named XSocketsMaxiServr in prior version) , now its called XSockets.DevelopmentServer.Console.exe , and can be found in the XSockets\DevelopmentServer folder or the project where you install.
By just opening it from the "command prompt" the server starts, registers the WebSocketHandlers of yours. The examples that will be added during install, is located under XSockets\Examples.
We will update the documentation in just a few days, and i also know that Ulf , a team-member of XSockets just recently publised a new guide/video that can be found here:
http://xsockets.net/videos
The movie is called "XSockets.NET 1.0 RC1 - getting started" and im sure that i will be helpfull for you.
If you need any assistance don't hesitate to contact us, we will assist you as much as possible! You will find the correct contact information at the XSockets WebSite.
Kind regards, Magnus Thor, Team XSockets.NET
I have a project consisting of a windows client (approx. 150 users), a webservice and some windows services. All together working in an intranet and build using C# .NET 3.5. Now I want to log exceptions in a central database and manage them (watch top 10, ticket system, etc.) via a web application.
I thought about using and expanding ELMAH, because it already has an web application for management. Maybe create a webservice for the clients to log their exceptions.
Is that a good idea, because ELMAH is obviously intended for asp.net web sites only.
I am aware of the Exception Management Application Block, but as far as I know it has no management application like ELMAH, plus my last visit at the Enterprise Library was no fun.
What is your opinions, are there other ideas?
Enterprise Library is cumbersome and overkill. Look at open source logging components: NLog link text or Log4Net link text. They both have the capability to log to various "sinks" including a flat file, UDP, database, etc.
I would set something up where your logging component writes to the event log on the server. Then use something like Microsoft Operations Manager (MOM) or another systems management software that can scan the event log and raise alerts via paging, command-center console, etc. At the same time, you could also log to a database for querying, etc.
If you are looking for management of exceptions, reporting, alerting, etc... There are tons of solutions like MS MOM, Tivoli, CA Unicenter, HP OpenView, and even NagIOS that you could use for this.
The client-side is a bit more tricky. Since it is intranet, you could use UDP and run a service on the server that will listen for those UDP packets and store them in the event log and/or a database. Or you could add some methods to your web service to capture logging events.
I don't think that your idea to expand ELMAH is a bad one at all. Having done many similar projects I've always had to roll my own management apps and it is always a pain. Not sure how much you will be able to use from ELMAH but it sounds like it might be a great starting place.