.net - WCF - calling back to client (duplex ?) -
i have problem solution choose.. have server running having service running can receive orders website. server several client (remote computers) connected somehow.
i use wcf comunication, not sure it's possible.
i dont wanna configure client firewall settings in routers, clients have connect server.
but when order recieved on server, should transferred specific client.
one solution have client connect using duplex binding, have somehow keep connection alive in order able received data server... way ??
normally connection times out , reason...
anyone have insight problem.
thx alot advise :-)
best regards søren müller
this duplex bindings designed for. 2 best choices have nettcpbinding or pollingduplexbinding.
the former uses tcp protocol may not suitable clients if aren't on network. however, allow two-way communication on client-initiated socket. client doesn't need able accept incoming connections. used on project , works well. it's responsive. when client applications close, session on server ends.
the second option, pollingduplexbinding included in silverlight sdk. uses client-initiated "long" http request. request waits messages need go out client , when arrive, client request returns. client initiates new http request server. in other words, client has pending http request. works on firewalls , should used when you're dealing internet clients. however, i've found not responsive nettcpbinding. may have been doing wrong seemed attempts send callbacks abandoned client sessions took while "time out".
here's example of configuration file recent project used nettcpbinding duplex communication. note other tweaks service throttling pretty using defaults binding. there's kinds of things can tweak such receivetimeout, inactivitytimeout, etc.
<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 initiate session } [operationcontract(isoneway = true)] public void publish( broadcastmessage message ) { // client calls broadcast message // 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
Comments
Post a Comment