Callback from WCF to Flash (AS3) - c#

I have an client server software that uses WCF duplex channel to connect them.
Most of the communication is done from the client to the server but i also have some callbacks from the server to the client.
My problem begins with the fact that i need to allow flash client to consume that data from the server.
I added another endPoint with basicHttpBinding so the flash client will be able to connect to it and now i am stuck without a solution to the callback.
What is the best solution to allow duplex connection between the flash client and the server ?

I managed to find a solution and now i am testing to see if it will fit my needs,
Long Puling between the flash client and my WCF service,
It means that the client will need to make a call to the server and the server will hold that connection and wont return until he will have an update (or if i will define some timeout for the connection)
After the client will receive an answer (return value) from that function he will make that call again.
This way i can simulate a callback from the server to the client,
Hope it will help someone.
When i will be done i will upload some code

Related

HTTP and SignalR

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.

Send commands to another network

I am trying to write a monitoring tool to monitor some information
It will gonna work on azure normally. So i gonna host the database on azure also the webservice will be hosted at azure.
On the client's i read from the config file how many time's he need to update the information to the azure database ( with the webservice on azure ).
Now i want to send also some commands to the client itself. Like start service, .... what is the best way to do that?
How can i send it from a website that is hosted on the azure platform?
I think you should consider implementing a WCF service at the client as well. The Azure side of your software could call operations from this service when it needs to instruct the client to do something.
The WCF service at the client should be something simple,hosted in a Windows Service or in your actual client (whatever it is... win forms, console, etc).
Since you have no VPN, it sounds like you may have a problem with hosting a WCF service on the client. If the client is behind a firewall, you would have to modify the firewall configuration to allow your server to connect to this service.
Last time I had to do a service like this, I used Comet. The server maintains a queue of messages to be sent to the client. Your client connects to the web service and requests any available messages. If messages are available, the server returns them. If not, the server leaves the request open for some time. As soon as a message arrives, the server sends it down the already-open connection. The client will either periodically time out/reconnect or send a keep-alive message (perhaps once per minute) in order to keep the connection alive in the intervening firewalls.

Execute Client Function from Server

After looking into WCF, I don't believe it can do what I need it to. What would be the appropriate way (if I have a server and client application, both C# .NET Console apps) to basically instruct the client to execute functions?
For example, if the client application has functions such as DownloadFTPFile(), CreateWindowsService(), IsServiceRunning(), etc. what would be the standard approach to telling them to execute this from the client?
I was initially just going to have the client interpret messages sent from the server, such as "downloadfile ftp://filename.zip" but I am wondering if there is a better way.
Client has Agent.
Agent connects to server, polls for cmomands
Agend executes comands.
THe server sending is tricky unless you control the environment. NAT for example makes "client sends" a nightmare. You also then open up the client for additional attacks with client polling the clietn firewall does not have tp open external access to the agent.
It is possible.
Use the callback functions along with duplexes in the WCF. You will be limited to the intranet usage or azure though, since only NetTcpBinding and NetTcpRelayBinding support it (WsHttpBinding is deprecated).
With WCF, any client can self-host a WCF service. This can make the client be a service. Add a little extra protocol between the client and the service, and you've got your wish.

How can I "bridge" VNC traffic from two clients connected to a C# proxy-type server?

I'm looking to develop an asynchronous C# TCP server which can act as a proxy between two client VNC connections, passing data between the two transparently.
I've already got some asynchronous client-server code set up where I can effectively communicate messages between the server & any connected clients, now I need a way to host a kind of proxy for VNC traffic.
Client A--------------Server--------------Client B
VNC traffic sent -> relayed through server -> VNC traffic received
And then any response from client B to simply flow back to the server, then transitively to client A.
If any more information is required for a proper answer, please do let me know.
Thanks!
I managed to get this answered on Server Fault...the key is to launch "socat" from your application and use it to "link" the connections together.
See: https://serverfault.com/questions/254855/socat-connect-connect-proxy-two-inbound-tcp-connections-to-expose-a-firewalled
For more information.
You say that you already can receive data on the server that is sent from the client - you just write exactly what you read from one client back out to the other connected client.
It seems like you've already done the hard work, and I'm confused as to what part you're not understanding on how to finish it up.

Easiest for two way communication over the internet using C#

What do I use for two way communication over the internet without the necessity to open ports on the client side?
Users won't agree to open ports and do port forwarding on the client side although everything is possible on the server side.
But,I need to accomplish two way communication..
How do I go about achieving this?
It doesn't matter whether its WCF or remoting or webservices...
I just need a quick and fast way to just get the concept to work out and distribute the application.
ofcourse,it's going to be through the internet.
Please help..
Thanks
Edit : Please note that i need to connect multiple clients and maintain a session for each client.
WCF supports duplex HTTP bindings.
As long as the initiating client can access the service, a callback contract can be defined to call the client. It simply keeps the HTTP connection once the client has initiated it.
It depends what you want to do. Duplex WCF can work, but through NAT and Proxies it becomes somewhat "iffy" because it depends on the client opening a WCF endpoint and maintaining the connection.
I wrote a beginners guide to WCF callbacks a while ago - it's simple enough to do, but you'll need to test it a lot, from various client setups.
Connect via TCP (raw sockets, or higher implementation) to a your central server.
Your server should have an application that listens to a specific, well known, TCP port.
Each client connects to your server, using the specific port, and "logs in".
Write an application protocol above the TCP (authentication, session management, etc.), and there you have it, since a TCP connection, once established, works for both directions.

Categories