SignalR Server Self Host - c#

I need to create a SignalR server self hosted. I need to put the client on another persons machine to show a demo that pushes data from a remote client on the network to the server to be rebroadcast to any other connected clients. I have created a signalR server in both windows forms and an asp.net application and they run. However the URL is Localhost:12345 and works only on my local box. I need to allow other remote clients to connect either with my system IP or a URL.
Thanks

Related

Is it possible to communicate between 2 gRPC services in one ASP.NET Core application?

There is a solution of 3 projects (client (.NET WPF), server (ASP.NET Core gRPC (will run as a Windows service)), agent (.NET Console application (runs on the same PC as the server, but in user session)).
The server must have 2 separate services (one that communicates with the remote client and one that communicates with the local agent).
When a client's request is received, the server "forwards" it to the agent, the latter executes the request and returns the answer to the server, and then the server sends this answer to the client that asked for it.
Is it possible to implement this? And if so, how? I don't understand it at all...
P.S: I need it for the client to get screenshots from the server, but since the server is a Windows service, it cannot take those screenshots. The idea is that if the client asks the server to "ask" the agent to take a screenshot and send it to him, then the server will send the screenshot to the client.
Client-server (bidirectional streaming)
Agent-server (bidirectional streaming)
The flow you are describing is fairly straight-forward and is similar to how HTTP proxies proxy browser requests.
Run the snippet below you will see the flow I'm describing where the client makes a request to the server, the server then forwards the request on to the agent. The agent then responds to the request from the server using the same connection as the request from the server, and the server responds to the client using the same connection the client sent the request over.

TCP connection to client internal port with Blazor server app

I want to make a website that connects to a clients internal server through a TCP connection in order to get a stream of data from an internal server in the clients computer (at a specific port).
There is a 3rd party program that when running simulations creates a 'telemetry server' at a specific port in the clients computer. I want my website to connect to that port on the clients computer and do stuff (plots) with that output.
I read about Blazor server-side app and though I give it a try since I know C# and I already wrote a program to graph said telemetry output data in C#. Now I want to make my program available to others though a website.
My program connects through System.Net.Sockets.TcpClient without problem. I even tested the connection on Blazor server-side app and it connects when the server is running on my computer.
System.Net.Sockets.TcpClient tcpclnt = new System.Net.Sockets.TcpClient();
state = "Connecting.....";
tcpclnt.Connect(myIp, 15151); // Telemetry server in port 15151
stm = tcpclnt.GetStream();
The problem is when I host my Blazor website in Azure, it is not longer able to connect. I tried writing my public IP in myIp and it doesn't work.
Unfortunately I don't get info error output from Blazor since the website just freezes with "An error has occurred..." message.
I don't know much about this (TCP connections, web connection rules, ports..) and would appreciate any leads on what could be wrong or if it is even possible.
EDIT:
I'm using server-side as suggested here since a client-side app wont be allowed to connect How can I use Socket in Blazor Client-side?
Are you using a Azure web app?
You might want to consider adding Azure Network Gateways to handle Routing rules. I think all apps and VM's in Azure need a application gateway to communicate outside of the Azure subnet.

Hosting a C# Remoting Application

i have created an Chat Application in C# using TCPChannel and Remoting Service. My Application have 3 parts one is remoteobject, second is RemoteServer and third one is ClientSide. Everything is Working fine in my pc, mean if i run server application and client application in same server its works very good, because localhost. but when i try to host my server application in my VPS and client application in my pc then i can not connect with my server application. how can i specifies an Static IP to my Server Application so i can access my app from anywhere. please help
You may want to check out your firewall settings. You will need to open a port to allow outside traffic to access the particular port on your machine.
this constructor is using a fixed port: https://msdn.microsoft.com/en-us/library/cdb9dcxt(v=vs.110).aspx

How can server application check if a client application is online?

I have a server application which monitors the clients' activities in the network (all codes are in C# winforms). The server application already has IP addresses of client computers. I want to know how to check
i) if the clients are online (i.e, have opened and been using the client applications) or offline (not using the applications)?
ii) if the clients' computers are opened?
I'm not good in networking and have not got it after searching for hours on internet. Please help!
Edited: I have seen the mentions of HTTP, TCP, UDP, etc. in various sites about server-client applications. What are the differences between them and which one should be used for the above?
PS: Sorry for extra questions. The questions are related so I dont want to make a new post.
You could check if the client machines are online by pinging each machines using their respective IP address.
Ping ping = new Ping();
PingReply pingReply = ping.Send("IP Address");
if(pingReply.Status == IPStatus.Success)
{
//Machine is online
}
To check if client machines are using any particular application(if
those application are built by you and have access to source code).
you can use WCF inter process communication. basically you will create
a WCF service method and host in a managed environment. to be specific
you could host this service in your server win form application. As
long as your win form application is running in the server client
application installed in individual machines can call this method to
send a status(including individual IP address of machines). so server
app would know who is running/opened the specific client application
in each machine.
If you want to check the status of any other client applications, say
you want to get the status to server whenever a client machine runs a
"xyz" application. then you need a create a application which runs on
individual client machines(Windows service would be best option). job
of this application would be to check the running processes
periodically to see if any specific application process is running. if
then it will invoke the WCF hosted in your server app to send the
status.
Several options are available, following is a conceptual answer
Your server can maintain available clients in some list. Here you can include Time to live for a specific client (Like session expiring). You client need to send periodical flags to server to indicate that Client is still using the service and when Server get this reply it can update it list's session so it won't be expire.
Note - The list can be a small data structure which include clients IP and Last flag recieved time. Your server then can go through this list and check for expiration of a client (lets say when time stamp is older than 2 minutes Server assumes client doesn't use the service/not online)
Also other option is your server can send client a flag and get reply back periodically.
Simple Client Server -
http://www.codeproject.com/Articles/12286/Simple-Client-server-Interactions-using-C [Simple guide]
http://csharp.net-informations.com/communications/csharp-multi-threaded-server-socket.htm [Multi threaded]

c# socket server - deploying, starting, stopping

I'm a little confused when it comes to socket servers in terms of deploying it online.
Running locally is fine as most tutorials get you to make a server application and a client application which I can execute. Done all that for awhile now and I'm happy with it but now I want to try it using a web host.
How would I deploy the socket server to my web host and then run the server? do I just upload the program to the server and run www.mywebpage.com/mysocketserver (assuming the program is called mysocketserver.exe)
may sound like a stupid question but I'm having one of those brain dead moments.
[Edit]
Great answers guys thank you. Shame I can only mark one as the answer.
Most hosting services are website related: you upload your website to their server and the host takes care of provisioning the application.
However you haven't written a website that is served by a web server, but a socket server, which is more akin to the web server itself that runs a website.
As a result you will need a host that will allow you to install and run applications, such as a Virtual Private Server service, rent a physical server or use a cloud service such as Amazon EC2.
You usually Remote Desktop or SSH into the server you are renting (or own) to upload and start the application either as a normal application, a Service or a Daemon.
Once you have installed your socket server on the host server and started the application running you should be able to contact your service using the IP address for your server and the port that you are running your socket server on.
For example, if your ip address is 10.0.0.1 and you've written your socket server to listen on port 1234, you should be able to contact your service at address 10.0.0.1:1234.
Take into account firewalls allowing access to that port.
You will also then be able to use a DNS service such as DynDns to assign a domain name to that ip address.
You can't do that unless your socket server is using HTTP as a protocol.
You are using a port for your server, right? The ports are used to identify which application to talk with.
When you browse the web using "http://something" you really say let me get the stuff which can be found on the IP 1.2.3.4 (DNS lookup) using port 80 (which is registered for HTTP). You don't have to specify the port in the browser since all browsers know that HTTP uses port 80.
So what you are really should do is to put the socket server on your host and tell your customers/users that they can connect to your socket server at port XXX on host "www.mywebpage.com".
If you've built a client you'll just hard code the port in it or specify the default port automatically.
The problem in the Internet is the routing/name translation, so that mywebpage gets translated into the correct IP address.
Either your webserver needs a fixed public IP address or you need to use a service like dynds which will dynamically map your changing IP address to the static name.

Categories

Resources