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. Google Reader明日关闭:14款替代品对比

    北京时间6月30日上午消息,谷歌将于7月1日关闭RSS阅读器服务Google Reader,目前许多用户已转向其他的RSS阅读器服务. 美国科技博客Marketing Land本周对市面上多个RSS阅 ...

  2. delphi 主线程向子线程发送消息

    while True do begin if not PeekMessage(msg,0,0,0,PM_REMOVE) then begin case MsgWaitForMultipleObject ...

  3. [Git]git教程

    摘要 目前公司项目逐渐都要迁移到git上,使用git进行版本控制及源代码管理. git学习资料 一个小时学会Git 权威Git书籍ProGit(中文版) git官网:http://git-scm.co ...

  4. [经使用有效]Sqlserver2005附加数据库时出错提示操作系统错误5(拒绝访问)错误5120的解决办法

    sqlserver2005附加数据库时出错提示操作系统错误5(拒绝访问)错误5120的解决办法 最近几天从网上找了几个asp.net的登录案例想要研究研究代码,结果在用 Sql Server2005附 ...

  5. AngularJS一个由于未声明对象而报的错

    实现这样的一个需求:点击某个按钮,然后显示或隐藏某块区域. 先注册一个AngularJS的一个module: var myApp = angular.module("myApp", ...

  6. C#编程(十三)----------方法重载

    C#支持方法的重载---方法的几个版本有不同的签名即可(即,方法名相同,但是参数个数和/或类型不同).为了冲在方法,只需要声明同名单参数个数或类型不同的方法即可. 注意:两个方法不能仅在返回类型上有区 ...

  7. python测试开发django-22.admin首页和title修改

    前言 django的admin首页默认显示的"Django 管理",title显示的是"Django 站点管理员",这里的文案内容可以修改成自己项目的后台页面内 ...

  8. webrtc在ubuntu14.04上的编译过程(12.04亦可)

    转自:http://blog.csdn.net/xiangjai/article/details/44409751 一.虚拟机环境搭建 1.安装ubuntu 14.04虚拟机: 因为可以屏蔽svn版本 ...

  9. BadgeValueView

    BadgeValueView 效果 源码 https://github.com/YouXianMing/UI-Component-Collection 中的 BadgeValueView // // ...

  10. Git: Push rejected 的解决方案

    Push rejected: Push to origin/master was rejected 首先,git init (在工程文件夹下) git remote add [-t <branc ...