C# WCF TCP Error code 10060 & 10061 Problem
Hej,
har precis börjat koda för WCF(Windows Communication Foundation) igen och som vanligt så har det uppstått ett problem. Får nämligen TCP Error Code 10060 när någon försöker ansluta till min server, och TCP Error Code 10061 när jag försöker koppla upp mig lokalt - fast med min externa IP-Adress.
Har försökt klura ut vad tusan felet kan vara men lyckas helt enkelt inte.
Har lagt upp en tråd på Stackoverflow för den som är intresserad.
TCP Error Code 10060: A connection attempt failed because the connected party did not properly
respond after a period of time, or established connection failed because connected host has
failed to respond IP-Adress:3100.
TCP Error Code 10061: No connection could be made because the target machine actively refused it.
Servern:
svh = new ServiceHost(typeof(ServiceAssembly.ServiceImplementation));
NetTcpBinding tcpBinding = new NetTcpBinding();
tcpBinding.MaxConnections = 100;
tcpBinding.MaxBufferPoolSize = (int)4096;
tcpBinding.MaxBufferSize = 4096;
tcpBinding.MaxReceivedMessageSize = (int)4096;
tcpBinding.TransactionFlow = false;
tcpBinding.Security.Transport.ProtectionLevel =
System.Net.Security.ProtectionLevel.EncryptAndSign;
tcpBinding.Security.Transport.ClientCredentialType =
TcpClientCredentialType.Windows;
tcpBinding.Security.Mode = SecurityMode.None;
svh.AddServiceEndpoint(
typeof(ServiceAssembly.IChat),
tcpBinding,
"net.tcp://localhost:3100/MyService");
SynchronizationContext.SetSynchronizationContext(new SynchronizationContext());
Console.WriteLine("Starting server...");
try
{
svh.Open();
}
catch (Exception e)
{
Console.WriteLine("Error: " + e.Message);
}
Klienten:
public string m_ipAdress = "XX.XXX.XXX.XXX";
string m_port = "3100";
DuplexChannelFactory<IChat> scf;
IChat s;
private void login_btn_Click(object sender, RoutedEventArgs e)
{
Callback callback = new Callback();
InstanceContext context = new InstanceContext(callback);
NetTcpBinding tcpBinding = new NetTcpBinding();
tcpBinding.MaxConnections = 100;
tcpBinding.MaxBufferPoolSize = (int)4096;
tcpBinding.MaxBufferSize = 4096;
tcpBinding.MaxReceivedMessageSize = (int)4096;
tcpBinding.TransactionFlow = false;
tcpBinding.Security.Transport.ProtectionLevel =
System.Net.Security.ProtectionLevel.EncryptAndSign;
tcpBinding.Security.Transport.ClientCredentialType =
TcpClientCredentialType.Windows;
tcpBinding.Security.Mode = SecurityMode.None;
scf = new DuplexChannelFactory<IChat>(context, tcpBinding,
"net.tcp://" + m_ipAdress + ":" + m_port + "/MyService");
s = scf.CreateChannel();
try
{
s.Connect();
}
catch (Exception ex)
{
MessageBox.Show("ERROR: " + ex.Message);
}
}
Är tacksam för all hjälp jag kan få.. så sjukt irriterande bara.
NZXT H510 Flow MSI B450 Tomahawk MAX
AMD Ryzen 5800X3D RX 7900XTX Kingston Fury 64GB