I have a client server application written in C# .Net 2.0. I have had the client/server response/request code running for 4 years(!). Recently, on a specific machine, the client can not connect to server:

on the code line:

HttpWebResponse response = (HttpWebResponse)request.GetResponse();

WebException: The remote server returned an error: (503) Server Unavailable.
Message="The remote server returned an error: (503) Server Unavailable."
Status System.Net.WebExceptionStatus.ProtocolError

I believe this issue is machine-specific since i never had this issue on any other machine.

Is there something I need to configure on that machine? What did I miss?

HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(string.Format("http://{0}:{1}/", server, httpPort));

request.ContentType = "application/x-www-form-urlencoded";

string msgStr = msgString;

byte[] buffer = Encoding.UTF8.GetBytes(msgStr);

request.ContentLength = buffer.Length;

request.Method = "POST";

 

try {

System.IO.Stream requestStream = request.GetRequestStream();

requestStream.Write(buffer, 0, buffer.Length);

requestStream.Close();

requestStream.Dispose();

 

HttpWebResponse response = (HttpWebResponse)request.GetResponse();

 

byte[] inBuffer = new byte[10000];

Stream responseStream = response.GetResponseStream();

int iBytes = responseStream.Read(inBuffer, 0, inBuffer.Length);

 

StringBuilder sb = new StringBuilder(10000);

 

while (iBytes > 0) {

sb.Append(Encoding.UTF8.GetString(inBuffer, 0, iBytes));

iBytes = responseStream.Read(inBuffer, 0, inBuffer.Length);

}

 

response.Close();

responseStream.Close();

responseStream.Dispose();

 

if (!string.IsNullOrEmpty(sb.ToString())) {

message = HandleMessage(sb.ToString());

} else { //bug 58

message = HandleEmptyMessage(msgString);

}

} catch (System.Net.WebException we) {

_connected = false;

EventsHelper.AsyncFire(ConnectionLost, this, EventArgs.Empty);

throw new Exception(we.Message);

}

 

[Answers 1]

If it is only one machine it is probably environmental. It could be a DNS issue, a firewall issue, a router issue, an ISP issue

 

[Answers 2]

Thanks Jared! it was indeed a wrong network configuration.

 

 

From: https://stackoverflow.com/questions/14504165/remote-server-returns-error-503-server-unavailable

 

 

 

HttpWebRequest: Remote server returns error 503 Server Unavailable的更多相关文章

  1. 静态属性,直接把iis搞垮掉 Http error 503 Service Unavailable

    属性有个好处,可以在get的时候做一些特殊处理,比如返回一个默认值,正是这个特性,吸引我讲静态字段修改了成静态属性,代码如下: public static string 微信订阅号 { get { i ...

  2. http Error 503 server unavailable

    服务器的环境为: 系统:Windows server 2008 64位 数据库:Oracle 10g WEB应用服务:IIS 7.0+.Net Framework 4.0 无法打开服务元数据库路径“/ ...

  3. xp操作系统下配置iis,出现了server application error的解决办法

    在网上搜索了很多解决办法,最后发现一个差不多的: Server Application Error The server has encountered an error while loading ...

  4. server application error应用错误

    本地使用IIS测试ASP脚本网页,结果发现提示[Server Application Error The server has encountered an error while loading a ...

  5. 解决IIS的Server Application Error

    问题描述一下: Server Application ErrorThe server has encountered an error while loading an application dur ...

  6. appium报错:An unknown server-side error occurred while processing the command. Original error: Could not proxy command to remote server. Original error: Error: read ECONNRESET

    Appium Desktop版本:1.9.0 xcode版本:9.4.1 测试机:iPhone7  11.3系统 问题描述:在xcode上的produc的text运行是可以将WebDriverAgen ...

  7. 报错:Original error: Could not proxy command to remote server. Original error: Error: read ECONNRESET

    问题:Appium的android真机启动手机时,会遇到以下问题: An unknown server-side error occurred while processing the command ...

  8. Error from server error dialing backend remote error tls internal error

    # kubectl exec -it mysql-master-8cfb64ff9-ct4dx -n prophet -- /bin/bash Error from server: error dia ...

  9. windows Server 2008 IIS7 503错误解决方案

    windows 2008 R2 在访问的时候经常会出现503错误,于之前使用的是默认配置,服务器最多只能处理5000个同时请求,今天下午由于某种情况造成同时请求超过5000,下面是具体的解决方案: w ...

随机推荐

  1. ftp通用类1

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.N ...

  2. Java 微服务实践 - Spring Boot 系列

    https://segmentfault.com/l/1500000009515571

  3. 用xcode 5 开发访问IOS 7上面的通讯录有问题

    NSMutableArray *addressBookTemp = [NSMutableArray array]; ABAddressBookRef addressBooks = ABAddressB ...

  4. C#编程(三十四)----------数组作为参数

    原文链接: http://blog.csdn.net/shanyongxu/article/details/46765267 数组作为参数 数组可以作为参数传递给方法,也可以从方法中返回.要返回一个数 ...

  5. 【Devops】【docker】【CI/CD】3.Jenkins+GitLab+docker+springboot 实现自动化部署

    ==================================================================================================== ...

  6. 在Android.mk文件中输出打印消息

    http://www.xuebuyuan.com/1947880.html 在进行Android NDK的开发当中有时想看看Android.mk文件当中某个变量的值,可以再Android.mk文件当中 ...

  7. String转Date的类型转换器

    import org.apache.commons.beanutils.Converter; import org.apache.commons.lang.StringUtils; /* * 定义转换 ...

  8. unity,荧光效果(bloom)实现过程

    两个月前,刚接触unity的时候费了半天劲儿做了个荧光效果(见:http://www.cnblogs.com/wantnon/p/4430749.html),今天终于抽空整理了一下,把过程写下来. 荧 ...

  9. SharePoint SPUtility.SendEmail 发送邮件设置级别

    前言 熟悉sharepoint开发的都知道,sharepoint默认有个发送邮件的方法,不过,最近有个需求,用户希望发送邮件的时候,带上邮件的级别. 经过研究,发现有下面的办法,可以添加邮件的发送级别 ...

  10. 暴君第一季/全集Tyrant迅雷下载

    本季第一季 Tyrant Season 1 (2014)看点:虽然李安退出了FX系列剧<暴君>(Tyrant),称不想耽误了剧集的制作,但显然FX对这部剧的重视程度非比寻常,因为他们找来的 ...