.net - Can't access WCF websocket service from WPF application -


i'm trying use simple wcf service via websockets (nethttpbinding transportusage="always").

it works fine when consuming service console application, throws timeout error, when consuming wpf application:

this request operation sent http://localhost:8733/design_time_addresses/wcfservicelibrary1/service1/ did not receive reply within configured timeout (00:01:00).

there not timeout when switching transportusage="always" transportusage="never".

how can access websocket wcf service wpf application?

service contract:

[servicecontract] public interface iservice1 {     [operationcontract]     string getdata(int value);  } 

the service:

public class service1 : iservice1 {     public string getdata(int value)     {         return string.format("you entered: {0}", value);     } } 

the configuration:

<system.servicemodel>   <services>     <service name="wcfservicelibrary1.service1">       <host>         <baseaddresses>           <add baseaddress = "http://localhost:8733/design_time_addresses/wcfservicelibrary1/service1/" />         </baseaddresses>       </host>       <endpoint address="" binding="nethttpbinding" contract="wcfservicelibrary1.iservice1" bindingconfiguration="my_nethttpbindingconfig">         <identity>           <dns value="localhost"/>         </identity>       </endpoint>       <endpoint address="mex" binding="mexhttpbinding" contract="imetadataexchange"/>     </service>   </services>   <bindings>     <nethttpbinding>       <binding name="my_nethttpbindingconfig">         <websocketsettings transportusage="always"/>       </binding>     </nethttpbinding>   </bindings>   <behaviors>     <servicebehaviors>       <behavior>         <servicemetadata httpgetenabled="true" httpsgetenabled="true"/>         <servicedebug includeexceptiondetailinfaults="false" />       </behavior>     </servicebehaviors>   </behaviors> </system.servicemodel>  

console code (works fine):

    static void main(string[] args)     {          service1client c = new service1client("nethttpbinding_iservice1");         string s = c.getdata(8);         console.writeline(s);         console.readline();     } 

wpf code (doesn't work):

    private void button_click(object sender, routedeventargs e)     {         service1client c = new service1client("nethttpbinding_iservice1");         string s = c.getdata(5);         messagetextblock.text=s;     } 

the configuration identical both wpf , console application:

<system.servicemodel>     <bindings>         <nethttpbinding>             <binding name="nethttpbinding_iservice1">                 <websocketsettings transportusage="always" />             </binding>         </nethttpbinding>     </bindings>     <client>         <endpoint address="ws://localhost:8733/design_time_addresses/wcfservicelibrary1/service1/"             binding="nethttpbinding" bindingconfiguration="nethttpbinding_iservice1"             contract="servicereference1.iservice1" name="nethttpbinding_iservice1">             <identity>                 <dns value="localhost" />             </identity>         </endpoint>     </client> </system.servicemodel> 

i received answer on forum: it's deadlock on main ui channel.

a detailed explanation , workaround can found here:

http://blogs.msdn.com/b/dsnotes/archive/2015/09/22/wpf-winform-nethttpbinding-timeout-deadlock-issue-on-main-ui-thread-using-web-sockets.aspx


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -