How to send request from rest API to Windows Application - c#

as the question says, how can I communicate from a rest API to Windows application. I have Windows application that connects to a linux server over TCP connection. This application manages multiple connections (around 7-8k tcp connection on different ports and keeps alive these connections all the time.). I have a mobile application that connects to rest API (APS.net C#) and works as expected. Now i want to send some more information from linux server to mobile client. How can I send a request from rest API to windows application and get response to send it to mobile application when requested from mobile. This communication between API and Windows application should be asynchronous and could handle around 7-8k connections without delay. How can i achieve this? Is it possible to achieve this using current architecture? or should I change it? I am willing to adopt any proposed architecture or new framework and any other programming language which serves the purpose good. Here is rough structure.

I think you can try using SignalR, it allows for dual communication between client and serer
It uses websockets as its underlying connection and you can either send messages to all connected clients or a specific client.
https://dotnet.microsoft.com/apps/aspnet/signalr

Related

Should TLS1.2 changes be made for TCP Socket communication on LAN?

We are migrating our applications to communicate in TLS1.2. We understand that TLS1.2 will be the standard going forward. We have identified all the applications that communicate to the thirdparty web services and use HTTP communication. However we have few applications which communicate using sockets(Client and Server on LAN). My question here is, since the client and server are on the private network and the application is using Sockets to communicate, Should i make code changes to use TLS1.2?

What are some known ways to push data from web api to a windows form client

I'm having trouble finding some documentation or services available to help push data to clients on winforms. (Maybe my search query sucks)
Ex.
I open an application on my phone which sends a request to a web api controller to run some code in a windows form app that is already running somewhere else. (for example, my PC)
I can find an abundance of information on Azure Notifications Hub and push messaging when it comes to mobile devices and windows store 8 apps but not for plain old winforms app.
I am aware I can create a que on a db and poll it with clients but want to see if there is a way to avoid polling scenarios.
What are some known ways to push data from web api to a windows form client?
Learn About ASP.NET SignalR
ASP.NET SignalR is a new library for ASP.NET developers that makes
developing real-time web functionality easy. SignalR allows
bi-directional communication between server and client. Servers can
now push content to connected clients instantly as it becomes
available. SignalR supports Web Sockets, and falls back to other
compatible techniques for older browsers. SignalR includes APIs for
connection management (for instance, connect and disconnect events),
grouping connections, and authorization.
Here is a sample in the topic area.
Using SignalR in WinForms and WPF
Implementing SignalR in Desktop Applications
ASP.NET SignalR Hubs API Guide - .NET Client (C#)
This document provides an introduction to using the Hubs API for
SignalR version 2 in .NET clients, such as Windows Store (WinRT), WPF,
Silverlight, and console applications.
The SignalR Hubs API enables you to make remote procedure calls (RPCs)
from a server to connected clients and from clients to the server. In
server code, you define methods that can be called by clients, and you
call methods that run on the client. In client code, you define
methods that can be called from the server, and you call methods that
run on the server. SignalR takes care of all of the client-to-server
plumbing for you.

Call Windows Service from Browser

I want to send data to a driver software via browser application with in same machine. If this driver can keep on listening to external connection via socket as a windows service, can I write a web application to send data to this driver by using php, applet or .net. Driver is written in C#. Is this possible and if so can someone show me a path/suggestions or any resource related to this?
I do not know a whole lot about drivers...
But, if you can self-host a WCF service in the C# driver, than you can do IPC (inter-process communication) on the same machine. The WCF could expose multiple endpoints ie.) http, namedpipe, or tcp and the .NET web application can subscribe to the service and send data to the C# driver.
Also, if you use a http or tcp endpoint, i believe that the web application would be able to connect to the C# driver from another machine.
WCF Reference: http://msdn.microsoft.com/en-us/library/ms731082.aspx
you could use web sockets WebSocket, however your driver would have to handle the handshake.

Strategy for WCF server with .Net clients and Android clients?

I am using WCF to write a server that should be able to communicate with .Net clients, Android clients and possibly other types of clients.
The main type of client is a desktop application that will be written in .Net. This client will usually be on the same intranet as the server. It will make an initial call to the server to get the current state of the system and will then receive updates from the server whenever a value changes. These updates are frequent, perhaps once a second.
The Android clients will connect over the Internet. This client is also interested in updates, but it is not as critical as for the desktop client so a (less frequent) polling scenario might be acceptable.
All clients will have to login to use the services, and when connecting over the Internet the connection should be secure.
I am familiar with WCF but I am not sure what bindings are most appropriate for the scenario and what security solution to use. Also, I have not used Android, but I would like to make it as simple as possible for the person implementing the Android client to consume my services. So, what is my strategy?
with the small bit of android I have done.
the android sdk doesn't natively support soap server, you have to write it all your self.
Rest is your only option when working with WCF and android. Thats the way that Google are pushing you to develop apps.
WCF via HTTP transport is the way to go because it is not binary and does not make assumptions re all peers are .net/windows.
see this page for more info

Is it possible Connecting and sending message through GSM modem using asp.net?

I ve developed a c# winforms application for sending sms by using this article of Sending sms using GSM It works pretty well... Now i want to send sms using GSM communication (ie) a mobile phone connected to PC and i have detect it and send sms using it in asp.net.....
Is it possible Connecting and sending message through GSM modem using asp.net?
Of course you can! The only point is that, as ASP.NET is a server side programming, the GSM modem will have to be connected to the server running the app. Even, your already developed code can be reused. Put that code as an assembly with public interface to get the functionalities. Include it in the ASP.NET app and you can send SMS.
There should be no difference if your app is a regular console/winforms app or whether it's an ASP.NET app.
You would just want to be a bit more security-conscious if anyone on the internet is able to connect to your website and send messages...
Yes. You could create a Windows service that contains the logic for accessing the GSM modem and sending SMS messages. This service can then be access from your ASP.NET web application.
There are lots of articles out there on running a WCF service as a Windows service, here's one on MSDN, Hosting and Consuming WCF Services.
But on second thought, setting up a service may be overkill here. You could use your library from within your app just as fine.
You can do it as mentioned by Kangkan in his answer. You will need to connect your modem to the server which is less feasible and very much less recommended to do so. The best option you can have is to subscribe to a third-party SMS gateway and send SMS through their HTTP apis. There are many such providers available that provide this kindaa service. Just google them and you'll find the one that best suits your needs.

Categories

Resources