1

IPとポート番号を使用してtcpClient経由でローカルネットワークデバイスに接続するWindowsサービスを構築しました。ネットワークデバイスはデータをストリーミングし、読み取りを受け取ります。これは、複数のセットアップ(常に1台のマシン-> 1台のネットワークデバイス)のMONTHSで機能しています。

最近、ほとんどすべての接続試行が失敗し始めました!奇妙なことは、コマンドプロンプトを介してデバイスにpingを実行できることです。パテでは、データは転送されません。netstatを使用すると、リモートアドレスが表示されませんでした。

私のサービスでは、次のエラーログメッセージがあります。

 Exception by Establishing TCP/IP Connection@ServiceName System.Net.Sockets.SocketException (0x80004005): 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 XXX.XXX.XXX.XX:XXXX  (translated into english ;D)
   at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
   at System.Net.Sockets.Socket.Connect(EndPoint remoteEP)
   at System.Net.Sockets.TcpClient.Connect(IPEndPoint remoteEP)
   at System.Net.Sockets.TcpClient.Connect(IPAddress address, Int32 port)

これはネットワーク関連ですか?それとも、Windows Updateなどと関係がありますか?

私の最近動作しているコード

  public void readDevice()
        {

            TcpClient Client = new TcpClient();
            System.Net.IPAddress ip = System.Net.IPAddress.Parse(ConfigurationManager.AppSettings["IP"]);

                /*
                * Establishing TCP/IP Connection
                */
                try
                {
                    // IP and Port number  
                    log.Debug("Try Client.Connect:" + ip);
                    Client.Connect(ip, 5000);

                }
                catch (Exception ex)
                {
                    /* Handle the socket exception.... */
                   //this error is thrown
                    log.Debug("Exception by Establishing TCP/IP Connection@ServiceName "+ ex);
                }

                NetworkStream MessageStream = Client.GetStream();

      //Magic be here

        }

pingは可能ですが接続できないデバイスのため、私は本当に行き詰まっています。どんな助けでも大歓迎

4

1 に答える 1

0

I don't know how much help this will be, but it sounds like a network problem. If it just stopped working and nothing has changed code wise, I would start investigating there.

I had an issue like this with a server of mine, and the problem ended up being that the port forwarding tables got messed up so I was trying to connect to the wrong machine. I just fixed the forwarding, and blam-o! Everything worked great.

I hope your problem is as easy to solve.

于 2012-09-21T11:58:02.363 に答える