I am having a WCF duplex service with Silverlight client and .NET 3.5 WCF service.
The scenario I have is: during the duplex push OneWay operation from server to client if an exception happens in client notification handler the channel gets silently faulted so any further duplex calls from server timeout and fail. (As explained here One-Way Operations and Exceptions)
My question(s):
Can I just decorate with FaultContract a OneWay OperationContract, wrap the exception on client and prevent faulting of the channel?
if not, what would be some other way to catch the exception which occurred on the client during the duplex push from server?
When you use OneWay OperationContract, the receiver should not reply nor the sender of the request should expect one.
You can't.
Your best bet is you can create another OneWay OperationContract between client and the service so that the service can send the fault to the client.
Related
I'm creating a wcf project with a wpf client using mvvm design pattern,
Where do I need to implement the ICallback interface so I will be able to update the
window.
The callback contract should be implemented on the client-side. Likewise, the service contract should be implemented on the server-side, with which the server can send data to the client-side by the callback contract.
Please refer to my example of the previous post.
TimeOut exception in WCF while implementing duplex
the client sends a parameter to the server by using the service interface, subsequently, the server sends the handled result to the client with the callback contract so that the client application gets the updated.
Feel free to let me know if there is anything I can help with.
I am using SignalR Self Hosted Service(V 2.2.0) as server and using Silverlight as SignalR Client.
I am able to connect to the server and able to exchange the messages. I am having a button to stop connection to the SignalR service.
What I want is, When I click this button, Connection of that Client should get disconnected from SignalR Hub. I am able to get disconnected from SignalR Hub but it takes so much time to respond and my Client(Silverlight Web Application) gets into unresponsive state and comes back after around 28-30 secs. Is there any way to disconnect client immediately once the button is clicked?
This is because of a deadlock. SignalR client blocks the thread when sending the Abort request. However Silverlight wants to send the request on the UI thread. The default timeout for stopping the connection is 30 seconds so after the timeout the thread is unblocked and execution continues. This can be worked around by invoking stop asynchronously (await Task.Factory.StartNew(() => hubConnection.Stop());) or making the timeout smaller.
TL;DR;
https://github.com/SignalR/SignalR/issues/3102
I resolved my problem by calling hub disconnect method in Silverlight Threading task. So now I do not worry about acknowledgement of hub disconnect from SignalR.
I am using WPF and WCF for client server application. but i got a problem.
How to notify any update of client to other client.
Server(WCF)
Client1(WPF)
Client2(WPF)
if client1 enter any new record,immediatly notification send to client2 .
please suggest me best way to this complete task.
Thanks..
We have achieved such a requirement by using WCF Duplex Services. You can find enough information by googling about implementing a duplex service.
Basically;
clients send a client identifier (uniquely generated for each client) while registering to duplex service.
when WCF service updates data, pushes an update notification (including the notification source's client identifier) to all the registered clients
clients check for the originator's identifier when they got a notification. Discarding notifications caused by itself.
A few notes:
You can include everything about the updated data inside pushed notification payload to understand the change type or entity type.
Different bindings supported by duplex services. Usage of nettcpbinding is suggested if clients and service are in the same network and .net dependency is not a problem. You can find more information about support binding types from here or here.
I have a WCF service, hosted in a win form application, that receive the requests from the clients. One of this requests, is update the stock of the items.
Well, my idea is to use a client to send to the WCF service the new amount of items, then the service use Entity Framework 4.1 to update the database with the new stock.
How the service is duplex, when the services has finished the update, it sends a message to the client to notify that the operations is successful. That's if there is no problems.
However, I have a question. It's possible that the client send the command to the service to update the stock. The service receive the command correctly, but before the operation is finished, the client lost the connection with the service, so the services can't send to the client the status of the operation, so the user does not know if it's all ok or not.
My second question has the same logic, but with the WCF service. It's possible that the WCF service is installed in other computer different to the computer in which is installed the database. So it's possible that the WCF services send correctly the command to the database, but before the database notify that the operation is successful, the WCF service lost the connection, so it never receive a response from the database but the operation is successful. How can the user know if the operation is ok or not?
So my question is, in WCF, how can I be sure that critical operations are successful or not?
Thanks.
Daimroc.
I understand how I can use a raw socket to listen to a server application and recieve information but I need an easy to access API and I am very familiar with REST.
Is there a way to push (not by using long pooling) data using a WCF service?
Here's my idea of how things should happen, at least at the begining:
The client accesses a URI with it's access parameters (ip, port, apikey).
The server responses with success/failure.
The server opens a socket for each channel with the client's details.
The server accesses a URI indicating that all channels are now streaming.
But how do I wrap the client or the server socket to access a URI?
Edit:
Maybe I should open a socket that notifies about changes on a channel and on the client side require that it will listen and raise the event accordingly.
This is not a very generic solution isn't it?
You should look into the Net.TCP binding, as described by Tomek (one of the WCF team members) here. You use it more-or-less like you would use the HTTP Duplex binding (i.e., the HTTP Long Poll), but it's much, much faster. It's still more complicated than REST, but it's dramatically easier than sockets, and I don't think you'll find a REST-type solution that does what you need.