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. Unity3D使用碰撞体做触发器实现简单的自己主动开门

     在游戏制作中触发器的使用很的方便也很有用. 这一张我们简介一下怎样使用一个简单的触发器来实现自己主动开门关门的效果. 首先确保你已经对门进行了动画的设置. 详细流程例如以下. 选择Window- ...

  2. The STM32F746G-DISCO discovery board -- MBED

    https://developer.mbed.org/platforms/ST-Discovery-F746NG/ Microcontroller features STM32F46NGH6 in T ...

  3. HTML一些标签注意事项

    最近在IE10下运行一个以前的做web系统发现了两个小问题: 一.图片上使用"alt"属性来添加一些文字提示信息在IE10下无法正常显示出来 上网查了一下原因:原来是现在一些较新的 ...

  4. 在TQ2440上运行perf,生成Flame Graph

    参考 http://www.cnblogs.com/helloworldtoyou/p/5585152.html  http://blog.csdn.net/mtofum/article/detail ...

  5. 在ASP.NET MVC中使用Knockout实践06,自定义验证、异步验证

    在上一篇中体验了Knockout.Validation的基本验证,本篇体验自定义验证和异步验证. 自定义验证规则 ko.validation有一个rules属性,专门用来存放验证规则,它是一个键值对集 ...

  6. Android:活动的简单使用

    2.1    活动是什么 活动(Activity)是最容易吸引到用户的地方了,它是一种可以包含用户界面的组件, 主要用于和用户进行交互.一个应用程序中可以包含零个或多个活动,但不包含任何活动的 应用程 ...

  7. Spring Boot 2.0 + zipkin 分布式跟踪系统快速入门

    原文:https://www.jianshu.com/p/9bfe103418e2 注意 Spring Boot 2.0之后,使用EnableZipkinServer创建自定义的zipkin服务器已经 ...

  8. JavaScript 检查是否是数字

    //---------------------------------------------------------- // 功能:检查是否是数字 // 参数: // str // 返回值: // ...

  9. 【GitLab】【GitHub】GitLab和GitHub的双向同步

    有这种需求,需要GitLab上的现有代码库,同步到GitHub上. 又有一种需求,需要将GitHub上的代码库,同步到gitlab上. 一.GitLab上的代码库,自动同步到GitHub上 大致需要三 ...

  10. ibatis.net:第三天,Insert

    手工生成主键的模型 xml 配置 <insert id="InsertUser" parameterClass="User"> INSERT INT ...