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. How to replace a value in web.xml with a Maven property?(转)

    <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-p ...

  2. 使用Oracle DBLink进行数据库之间对象的訪问操作

    Oracle中自带了DBLink功能,它的作用是将多个oracle数据库逻辑上看成一个数据库,也就是说在一个数据库中能够操作还有一个数据库中的对象,比如我们新建了一个数据database1.我们须要操 ...

  3. 安装express并创建工程

    安装express npm install express-generator -g 使用命令创建express工程, express projectName 生成express相应的工程结构 bin ...

  4. python测试开发django-12.models设置主键primary_key

    前言 django的models新增数据库表时,如果不设置主键,会默认新增一个id为主键,如果我们想自己设置一个字段为主键,需加个参数primary_key=True 默认id主键 新增一张用户表,表 ...

  5. 《王者荣耀》技术总监复盘回炉历程:没跨过这三座大山,就是另一款MOBA霸占市场了

    如今已经大获市场成功的<王者荣耀>一直是业内各方关注的对象,而我们也知道这款产品在成为国民级游戏之前,也遇到过一段鲜有人知的调优期.也就是在2015年8月18号正式不删档测试版本推出之后, ...

  6. Java并发编程的艺术(三)——volatile

    1. 并发编程的两个关键问题 并发是让多个线程同时执行,若线程之间是独立的,那并发实现起来很简单,各自执行各自的就行:但往往多条线程之间需要共享数据,此时在并发编程过程中就不可避免要考虑两个问题:通信 ...

  7. 实用ExtJS教程100例-011:ExtJS Form 使用JSON数据赋值和取值

    上一节中我们演示了ExtJS Form的异步加载和提交数据,本节中我们将演示如何使用JSON数据为ExtJS Form中的字段赋值和取值. 系列ExtJS教程持续更新中,点击查看>>最新E ...

  8. Orchard模块开发全接触8:改造后台

    后台默认提供了 Content 的管理,但是,所有的内容类型揉杂在一起,而我们需要更深度的定制一些功能,比如,我们只想管理订单,又比如,我们需要对注册用户进行管理.本篇的内容包括: 1:自定义 adm ...

  9. Java NIO 的前生今世 之四 NIO Selector 详解

    Selector Selector 允许一个单一的线程来操作多个 Channel. 如果我们的应用程序中使用了多个 Channel, 那么使用 Selector 很方便的实现这样的目的, 但是因为在一 ...

  10. Java NIO Test Case

    package org.zwl.test.nio; import java.io.IOException; import java.net.InetSocketAddress; import java ...