Sockets PubSub在转换到控制台应用程序后无法发布
我是酒吧/酒吧的新手,已经十年没有做过TCP了。。。请帮忙!我有一个windows窗体发布子应用程序,它工作得非常好。经过广泛的测试后,我将Pub应用程序转换为一个控制台应用程序,它最终将成为一个服务应用程序。。。问题是_proxy.PublishalertData,topicName1;在内部,SendEvent方法由于超时而失败 例外情况如下: 套接字连接已中止。这可能是由于处理消息时出错、远程主机超过接收超时或基础网络资源问题造成的。本地套接字超时为“00:00:59.9529953” 需要注意的是,整个应用程序在到达Publish命令之前运行不到59秒 我已经将WinApp和Console应用并排进行了比较,没有发现问题。。。我已经在谷歌搜索了6个多小时,尝试了我能想到的一切。请帮忙!!!请指出,如果我在做一些不太聪明的事情,比如遗漏了一些次要的,或者主要的愚蠢的细节!!!多谢各位 有效代码如下:Sockets PubSub在转换到控制台应用程序后无法发布,sockets,tcp,connection,timeout,subscription,Sockets,Tcp,Connection,Timeout,Subscription,我是酒吧/酒吧的新手,已经十年没有做过TCP了。。。请帮忙!我有一个windows窗体发布子应用程序,它工作得非常好。经过广泛的测试后,我将Pub应用程序转换为一个控制台应用程序,它最终将成为一个服务应用程序。。。问题是_proxy.PublishalertData,topicName1;在内部,SendEvent方法由于超时而失败 例外情况如下: 套接字连接已中止。这可能是由于处理消息时出错、远程主机超过接收超时或基础网络资源问题造成的。本地套接字超时为“00:00:59.9529953” 需
class Program
{
static void Main(string[] args)
{
PublisherClass pb = new PublisherClass();
pb.PublisherClassStart();
}
}
public class PublisherClass
{
public List<String> ListOfTopics = new List<String>();
public List<String> ButtonCreatedList = new List<String>();
public List<RData> DataList = new List<RData>();
private TcpListener tcpListener;
private Thread listenThread;
IPublishing _proxy;
private System.Timers.Timer tmrEvent;
/* static */
TcpClient QFeedClientChannel = null;
//call the entitiesmodel customer list and create all topics from the.... here...
public void PublisherClassStart()
{
CreateProxy();
_eventCounter = 0;
QueueViaTCPListener();
CreateTopics();
Console.WriteLine("Press any key to Send Data to Server");
while (true)
{
var Val = Console.ReadLine();
object sender = null;
EventArgs e = null;
SendEvent(sender, e);
}
Thread.Sleep(10000); // wait for connections and topics to stabilize and then start firing the timer.
tmrEvent = new System.Timers.Timer(100);
tmrEvent.Elapsed += SendEvent;
tmrEvent.Start();
}
static public void CreateTopics()
{
。。。
}
private void CreateProxy()
{
string endpointAddressInString = ConfigurationManager.AppSettings["EndpointAddress"];
EndpointAddress endpointAddress = new EndpointAddress(endpointAddressInString);
NetTcpBinding netTcpBinding = new NetTcpBinding(SecurityMode.None);
_proxy = ChannelFactory<IPublishing>.CreateChannel(netTcpBinding, endpointAddress);
}
void SendEvent(object sender, EventArgs e)
{
try
{
lock (ListOfTopics)
{
lock(DataList)
{
foreach (...)
{
...
alertData = PrepareEvent(topicName1, topicData);
_proxy.Publish(alertData, topicName1);
_eventCounter += 1;
//txtEventCount.Text = _eventCounter.ToString();
i++;
}
}
}
}
}
catch (Exception ex )
{
int i = 0;
}
//tmrEvent.Start();
}
已解决:问题出现在NetTCPBinding安全模式中。在代码审查期间,发布服务器中的安全性发生了更改,然后发生了一个不相关的紧急情况,需要几天时间才能解决,服务器无法正常工作;我没改成相配的。注意你的安全设置 NetTcpBinding NetTcpBinding=新的NetTcpBindingSecurityMode.None
你也不应该用“无”字!默认为传输模式…FYI:失败的代码行接近底部。。。异常中的整数只是调试代码,用于在。。。