“远程服务器返回错误:(502)错误的网关." [英] "The remote server returned an error: (502) Bad Gateway."

查看:2142
本文介绍了“远程服务器返回错误:(502)错误的网关."的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在发送短信的网站上工作

I m working on website which sms sending application

public string SendHighPriorityXMLtoValueFirst(long dateTicks, long targetNo, string msgType, string msgHdr, string msgDtls, string from)
        {
            try
            {
                WebProxy _webProxy = null;

                StringBuilder XMLforVauleFirstAPI = new StringBuilder();
                XMLforVauleFirstAPI.Append("");
                XMLforVauleFirstAPI.Append("<!DOCTYPE MESSAGE SYSTEM \"http://127.0.0.1/psms/dtd/messagev12.dtd\" >");
                XMLforVauleFirstAPI.Append("<message ver="\">");
                XMLforVauleFirstAPI.Append("<user username="\" mode="hold" />                XMLforVauleFirstAPI.Append(HPUserName);
                XMLforVauleFirstAPI.Append("\" PASSWORD=\"");
                XMLforVauleFirstAPI.Append(HPPassword);
                XMLforVauleFirstAPI.Append("\"/>");
                WriteSMSLog("SendHighPriorityXMLtoValueFirst|" + dateTicks + "|" + targetNo + "|" + msgType + "|" + msgHdr + "|" + msgDtls + "|" + from);

                try
                {
                    //SendXMLtoValueFirst(From, TargetNo, MsgDtls);
                    XMLforVauleFirstAPI.Append("<sms udh="\" coding="\" text="\" mode="hold" />                    XMLforVauleFirstAPI.Append(msgDtls);
                    XMLforVauleFirstAPI.Append("\" PROPERTY=\"0\" ID=\"");
                    XMLforVauleFirstAPI.Append(dateTicks);
                    XMLforVauleFirstAPI.Append("\">");
                    XMLforVauleFirstAPI.Append("<address from="\" mode="hold" />                    XMLforVauleFirstAPI.Append(from);
                    XMLforVauleFirstAPI.Append("\" TO=\"");
                    XMLforVauleFirstAPI.Append(targetNo);
                    XMLforVauleFirstAPI.Append("\" SEQ=");
                    XMLforVauleFirstAPI.Append("\"");
                    XMLforVauleFirstAPI.Append(1);
                    XMLforVauleFirstAPI.Append("\" TAG=\"NCDEX\" />");
                    XMLforVauleFirstAPI.Append("");
                }
                catch (Exception ex)
                {
                    WriteSMSLog("SendHighPriorityXMLtoValueFirst|Ex-->" + ex.Message);
                }

                XMLforVauleFirstAPI.Append("</message>");
                string strXML = XMLforVauleFirstAPI.ToString();

                string xmlparameter = System.Uri.EscapeUriString(strXML);
                string URL = Server.UrlPathEncode(ValueFirstAPIPath + xmlparameter + "&action=send");

                mVFRequestSentTime = System.DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss tt");

                string throughProxy = ConfigurationSettings.AppSettings["ThroughProxy"].ToString();
                if (throughProxy == "Y")
                {
                    string ProxyIP = ConfigurationSettings.AppSettings["ProxyIP"].ToString();
                    int ProxyPort = Convert.ToInt32(ConfigurationSettings.AppSettings["ProxyPort"]);
                    string McUserName = ConfigurationSettings.AppSettings["NwUserName"].ToString();
                    string McPassword = ConfigurationSettings.AppSettings["NwPassword"].ToString();
                    string McDomain = ConfigurationSettings.AppSettings["NwDomain"].ToString();

                    _webProxy = new WebProxy(ProxyIP, ProxyPort);
                    NetworkCredential _networkCredential = new NetworkCredential(McUserName, McPassword, McDomain);
                    _webProxy.Credentials = _networkCredential;
                }

                Uri objUri = new Uri(URL);
                HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(objUri);
                if (throughProxy == "Y")
                {
                    objRequest.Proxy = _webProxy;
                }
                WriteSMSLog("SendXMLtoValueFirst-->" + URL);

             HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();//here i get exeption  
                Stream objStrm = objResponse.GetResponseStream();

                byte[] buffer = new byte[500000];
                objStrm.Read(buffer, 0, 500000);

                ASCIIEncoding objEncoder = new ASCIIEncoding();
                valueFirstResponse = objEncoder.GetString(buffer);

                mVFResponseRcvdTime = System.DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss tt");
                return valueFirstResponse;

            }
            catch (Exception ex)
            {
                WriteSMSLog("SendHighPriorityXMLtoValueFirst|Ex-->" + ex.Message);
                return "Exception Occured.";
            }

        }


例外是"The remote server returned an error: (502) Bad Gateway."


exception is "The remote server returned an error: (502) Bad Gateway."

推荐答案

一些提示: http ://www.checkupdown.com/status/E502.html [ ^ ]
您最好与一些系统管理员联系,因为该错误不在您的代码中,而是由调用外部计算机引起的.可能您无权连接到该计算机
some tips: http://www.checkupdown.com/status/E502.html[^]
you better talk to some sysadmins since the error is not IN your code but caused by calling external machines. Probably you do not have the rights to connect to that machine


这篇关于“远程服务器返回错误:(502)错误的网关."的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆