【问题标题】:Error while writing to an Azure Worker role Input Endpoint写入 Azure Worker 角色输入终结点时出错
【发布时间】:2013-08-02 10:39:32
【问题描述】:

我正在尝试创建一个可以在 TCP 端口上接收消息的天蓝色应用程序。我已经配置了如下所示的输入端点:

端点名称:GPRS端点
类型:输入
协议:TCP
端口:10000

我的 azure worker 角色代码如下所示:-

TcpListener listener = new TcpListener(RoleEnvironment.CurrentRoleInstance.InstanceEndpoints["GPRSEndpoint"].IPEndpoint);
        listener.ExclusiveAddressUse = false;
        listener.Start();

 while (true)
            {
                Thread.Sleep(100);
                if (listener.Pending())
                {
                    Trace.WriteLine("Incoming Request", "Information");
                    TcpClient c = listener.AcceptTcpClient();  //waiting for client to connect
                    Stream s = c.GetStream();
                    StreamReader sr = new StreamReader(s);
                    string text = sr.ReadLine();

                    if (text != null && text.Length > 0)
                    {
                        Trace.WriteLine("Saving GPRS Packets into Storage Table", "Information");
                        //Saving GPRS Packets into Storage Table
                        Site site = new Site();
                        site.GPRSPacket = text;
                        var insertOperation = TableOperation.Insert(site);
                        siteTable.Execute(insertOperation);
                    }
                    c.Close();
               }

               Trace.TraceInformation("Working", "Information");
            }
        }

最后我的客户端程序是这样的:-

TcpClient c = new TcpClient();
            Console.WriteLine("\nConnecting to Azure...");

            IPAddress AzureWorkeraddress = IPAddress.Parse("168.63.239.54");
            //String AzureWorkeraddress = "http://clienttcpcloud.cloudapp.net/";
            //IPAddress AzureWorkeraddress = IPAddress.Parse("65.52.184.129");

            c.Connect(AzureWorkeraddress, 10000);  //Azure Worker Role's INPUT TCP Endpoint 168.63.239.54 or (http://clienttcpcloud.cloudapp.net/)
            Console.WriteLine("\n<<<<<<<<<<<<<<<<<<Server Connected>>>>>>>>>>>>>>>>>>\n");

            Console.WriteLine("Sending to Azure...");
            Stream s = c.GetStream();
            StreamWriter sw = new StreamWriter(s);
            sw.WriteLine(text);
            sw.Flush();
            Console.WriteLine("\n\nGPRS Packet Sent!!!");

            s.Close();
            c.Close();

我尝试将端口号更改为多个值,但仍然无法响应。我得到的错误是:-

**A Connection failed because the connecting party did not properly respond after a period of time, or the established connection failed, because connected host failed to respond 168.63.239.54:10000**

我真的不知道问题是什么.....

【问题讨论】:

  • edit- 我更改了端口并尝试更改部署云服务。还是什么都没有……

标签: azure azure-worker-roles tcplistener


【解决方案1】:

http://blog.maartenballiauw.be/post/2010/01/17/Creating-an-external-facing-Azure-Worker-Role-endpoint.aspx 有一个示例应用程序。您是否尝试过,并将它正在做的事情与您正在做的事情进行比较?

【讨论】:

  • 我也有 azure 的问题。我已经使用了该示例应用程序 - 最值得注意的是该示例应用程序中没有消耗或连接到 Worker Role。
  • 我发现本教程更有帮助。 msdn.microsoft.com/en-us/…
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-03-03
  • 1970-01-01
  • 1970-01-01
  • 2021-07-16
  • 1970-01-01
  • 2014-12-29
  • 1970-01-01
相关资源
最近更新 更多