I get a timeout exception whenever trying to connect to my selfhosted wcf.
This is config I have:
<configuration>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="MetaBehaviour">
<serviceMetadata />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="MetaBehaviour" name="WcfStreaming.LargeDataService">
<clear />
<endpoint address="net.tcp://localhost/LargeData" binding="netTcpBinding"
name="Tcp" contract="WcfStreaming.ILargeDataService" listenUriMode="Explicit" />
<endpoint address="net.tcp://localhost/LargeData/mex" binding="mexTcpBinding"
name="TcpMex" contract="IMetadataExchange" listenUriMode="Explicit" />
<endpoint address="http://localhost/wcfstreaming" binding="basicHttpBinding"
bindingConfiguration="" name="BasicHttp" contract="WcfStreaming.ILargeDataService" />
</service>
</services>
</system.serviceModel>
</configuration>
And here is hosting code:
host = new ServiceHost(typeof(WcfStreaming.LargeDataService),
new Uri[] { HttpUri, TcpUri });
host.Open();
var factory = new ChannelFactory<WcfStreaming.ILargeDataService>(new NetTcpBinding(), new EndpointAddress(TcpUri)); // Hnew NetTcpBinding(), new EndpointAddress(TcpUri));
srvChannel = factory.CreateChannel();
using (OpenFileDialog dlg = new OpenFileDialog())
{
if (dlg.ShowDialog() == DialogResult.OK)
{
Stream str = srvChannel.GetFile(dlg.FileName); //Exception here
StreamReader sr = new StreamReader(str);
string bf = sr.ReadToEnd();
File.WriteAllText(@"C:\test", bf);
}
}
I get nasty:
This request operation sent to net.tcp://localhost/LargeData did not receive a reply within the configured timeout (00:01:00). The time allotted to this operation may have been a portion of a longer timeout. This may be because the service is still processing the operation or because the service was unable to send a reply message. Please consider increasing the operation timeout (by casting the channel/proxy to IContextChannel and setting the OperationTimeout property) and ensure that the service is able to connect to the client.