WCF - client call (duplex?)

I have a problem with a solution. I have a server running a service that can receive orders from a website. Several clients (remote computers) are connected to this server somehow.

I would really like to use WCF for all communication, but I'm not sure that this is possible.

I do not want to configure all client firewall settings in my routers, so clients will have to connect to the server.

But when the order is received on the server, it must be transferred to a specific client.

One solution might be to connect the client using duplex binding, but it will have to somehow maintain the connection on the network in order to be able to receive data from the server ... Is this a good way to do this?

Usually the connection time ends and probably for a good reason ...

Does anyone have an understanding of this problem.

thanks alot for any tips :-)

Regards Søren Müller

+3
source share
2 answers

This is exactly what duplex bindings were created for. The two best options you have are: NetTcpBinding or PollingDuplexBinding .

TCP, , . , . , . , . . , .

, PollingDuplexBinding Silverlight SDK. "" HTTP-. , , , . HTTP- . , HTTP-. , -. , , NetTcpBinding. , - , , "-".


, NetTcpBinding . , , , . , , , getTimeout, inactivityTimeout ..

<configuration>
    <system.serviceModel>

        <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />

        <behaviors>
            <serviceBehaviors>
                <behavior name="">
                    <serviceMetadata httpGetEnabled="true" />
                    <serviceDebug includeExceptionDetailInFaults="true" />
                    <serviceThrottling maxConcurrentCalls="65535" 
                                       maxConcurrentSessions="65535" 
                                       maxConcurrentInstances="65535" />
                </behavior>
            </serviceBehaviors>
        </behaviors>

        <bindings>
            <netTcpBinding>
                <binding maxConnections="65535">
                    <security mode="None" />
                </binding>
            </netTcpBinding>
        </bindings>

        <services>
            <service name="BroadcastService">
                <endpoint address="" binding="netTcpBinding" contract="BroadcastService" />
            </service>
        </services>

    </system.serviceModel>
</configuration>

[ServiceContract( CallbackContract = typeof( IBroadcastCallback ) )]
[ServiceBehavior( ConcurrencyMode = ConcurrencyMode.Multiple )]
public class BroadcastService : IDisposable
{

    [OperationContract(IsInitiating=true)]
    public long Subscribe( Guid clientID )
    {
        // clients call this to initiate the session
    }

    [OperationContract(IsOneWay = true)]
    public void Publish( BroadcastMessage message )
    {
        // client calls this to broadcast a message to
        // all other subscribed clients via callback
    }

}

[ServiceContract( Name = "BroadcastCallback" )]
public interface IBroadcastCallback
{

    [OperationContract( IsOneWay = true, AsyncPattern = true )]
    IAsyncResult BeginBroadcast(BroadcastMessage Message, AsyncCallback callback, object state);

    void EndBroadcast( IAsyncResult asyncResult );

}   // interface
+4

, . .

WCF wsDualhttpbinding:
, IP-. http , . , IP-.

WCF NetTcpbinding:
TCP , , WCF. , TCP-. .

WCF NetHttpBinding -:
HTTP, . http-, TCP- . 8 2012 WCF. - 8 2013, .

- ( R, Xsocket.net):
WCF, - Windows. HTTP TCP

0

Source: https://habr.com/ru/post/1743287/


All Articles