I have several clients connected to a server using TCP. Because of some problems with the TCP (or the IT policies) I want to change the protocol to TCP using either web service or web API
The problem is that the HTTP is a request from client to server, but not the other way around
I want to create this option where the server can push responses to the client
Server:
.NET windows application with TCP connections, hold few clients each client has a logic instance
Client:
.net windows application with TCP connection
Because of the server architecture I don't want to use ASP.NET or other application rely on IIS.
Does WCF can provide me with this solution?
We use SignalR in one of our projects
NuGet package
Video Tutorial
IIS is not necessary, you can self-host this service (as we just do)
Related
I am recently learning about web sockets in .Net and have just found SignalR which seems like too good to be true in terms of the abstraction of what connection to use and it seems like there are a few signalr clients in different languages which is awesome.
In my current project different resources are being exposed through a RESTful API, and from my understanding of websockets the client needs to upgrade to a web socket connection through a HTTP request/response. Does signalR handle all this handshaking going on?
If there is an initial request/response from a GET request to retrieve a certain resource but they opt to upgrade to a socket connection, does the server give them any sort of response besides the response saying it acknowledges to open up a web socket connection or is the handshake all that occurs before the information is live updated for that particular resource?
Do you think signalR is scalable as opposed to implementing this through a protocol like STOMP where there are a large number of client libraries?
You are making things too complicated. A typical example of using signalr is:
an html file using JavaScript to connect to a signalr Server when the page is loaded. we call this signalr client.
a signalr server written in c#. it can be a winform or console or service.
the signalr Server can call any dll, or webservices or webapi located in the same server, or even in different Server.
then, the client can call any function defined in the signalr server. the server can call any function defined in the client for a particular client or for groups of clients.
also, client x can call client y functions as well.
you can actually forget about Web sockets, signalr choose the most appropriate transport protocol for you. it will choose Web sockets if it is available in both the server and the client.
I need simple way of communication between 2 desktop application over local network. Client application have to call server and trigger command execution on server desktop. RPC is the old way of doing that. Looks like WCF is new way.
If WCF, does it require IIS on the computer that is running server application?
Where I can find WCF sample code to follow?
For two Windows applications, you're probably going to want a self-hosted WCF service using Net TCP binding.
Self-hosted means the service is contained in your application (could be a desktop app or Windows service) - no IIS required. Just about any kind of binding will work, but Net TCP binding is ideal for .NET applications that only talk to other .NET applications over a LAN.
Here's a sample from MS on self-hosting.
You can host WCF in various ways - IIS, windows service, console application.
So no, you do not need IIS installed unless you want to host it on IIS.
Here are some examples on how to do it
Host a WCF Service in a Managed Windows Service
Host WCF in a Windows Service Using TCP
My server has two applications running on it:
TCP socket server that continuously accepts and sends messages to and
from clients (C# .NET Winforms)
ASP.NET application
What I need is:
When a message is received from a client via the TCP connection (app 1) I want the ASP .NET application (app 2) to reflect this data dynamically. I realise that I can set database entries via the TCP socket, which will then be picked up by the ASP.NET application.
A way of sending messages to clients from the ASP .NET application to clients that are available inside of the TCP socket server
e.g. A simple chat program where a client sends “Hi” and server responds “Welcome”. The ASP .NET should show a log of this conversation as it happens. Immediately. And if I click a button on the ASP application, it should send a message on behalf of the socket server to the client “You have been accepted onto the server”
For the most part, the messages are going to be fairly short like the ones shown here.
What is the best way to do A and B?
SignlaR is a good solution if you're getting the messages from another SignalR client (web page).
But what if these messages are being sent from a 3rd system over TCP/IP?
Then you need to open a TCP port in the ASP.NET Web Application and after receiving a message you have to push it to the web clients.
But the question is, what is the best way to have such a TCP Listener hosted in a Web Application (ASP.NET)?
if your "messages" are mostly textual, you may want to take a look at SignalR.
SignalR is a new library for asp.net to enable real-time web functionality.
It uses websockets (or long polling if websockets is unavailable at server/client).
It has support for different client types.
Im looking at this basic chat server/client tutorial using TcpClient in .NET. Now I would like this put the chat server online on my web hosting provider. Is that possible? Can I host this server in IIS somehow? I could probably just start it in Application_Start but I dont think Im allowed to open a connection on any port just like that. What options do I have? I have made a chat app using WCF and net.tcp before but my hosting provider has not activated net.tcp on their IIS-server. So now Im looking at using a TcpClient instead...
I'd avoid attempting to use TCP in shared hosting scenarios. Why not use a HTTP WCF service instead? Most hosts lock down most ports except standard 80/443 and a few others. I can't see that they would allow you to open an arbitrary tcp port from their server, it could be a big security risk.
I would not host a chat in IIS since you are limit to the application pool lifetime. Look after a hosting company that provides virtual servers instead.
Im trying to make a a cleint/server web application where eventually the client application will be deploy on the internet. People told me to use visual studio WCF duplex but im confuse on how that works. I know for a simple server/client application using sockets, u can just use console for the server and then a windows form for the client.
So how does WCF duplex work, will it be used for both the server and the client side or do i sill use console for the server?? Also how do they establish a connection, in sockets you use ip address and a port.. HELP!
There are many WCF bindings that enable full-duplex communication. WCF servers and clients are able to use sockets among other means of communication. With WCF you can still use the IP Address:Port address system to expose and consume services.
With WCF you still can use Console Apps, Windows Forms or Web Applications to expose or consume those services. It brings no restriction at this point.
WCF will provide flexibility, since once you want to change the binding or the address, you can do it in the configuration file, instead of doing it by changing the code.