HttpWebRequest: Remote server returns error 503 Server Unavailable
|
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. 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的更多相关文章
- 静态属性,直接把iis搞垮掉 Http error 503 Service Unavailable
属性有个好处,可以在get的时候做一些特殊处理,比如返回一个默认值,正是这个特性,吸引我讲静态字段修改了成静态属性,代码如下: public static string 微信订阅号 { get { i ...
- http Error 503 server unavailable
服务器的环境为: 系统:Windows server 2008 64位 数据库:Oracle 10g WEB应用服务:IIS 7.0+.Net Framework 4.0 无法打开服务元数据库路径“/ ...
- xp操作系统下配置iis,出现了server application error的解决办法
在网上搜索了很多解决办法,最后发现一个差不多的: Server Application Error The server has encountered an error while loading ...
- server application error应用错误
本地使用IIS测试ASP脚本网页,结果发现提示[Server Application Error The server has encountered an error while loading a ...
- 解决IIS的Server Application Error
问题描述一下: Server Application ErrorThe server has encountered an error while loading an application dur ...
- 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 ...
- 报错: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 ...
- 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 ...
- windows Server 2008 IIS7 503错误解决方案
windows 2008 R2 在访问的时候经常会出现503错误,于之前使用的是默认配置,服务器最多只能处理5000个同时请求,今天下午由于某种情况造成同时请求超过5000,下面是具体的解决方案: w ...
随机推荐
- CentOS下KVM增加磁盘/磁盘扩容/在线扩容
一.磁盘镜像操作(适用于raw和qcow2格式) 1.创建镜像 qemu-img create -f qcow2(格式) /kvm/centos1_1.qcow2(路径) 5G(容量) 2.修改镜像容 ...
- HappyJTAG2 - JTAG AND SPI AVR8 interface EMBEDDED JTAG ! EMBEDDED SPI !
New version released ! V2.45 (Check version list for details) This construction is based on HappyJTA ...
- tomcat开启SSL8443端口的方法
参考文献: http://tomcat.apache.org/tomcat-7.0-doc/ssl-howto.html http://blog.sina.com.cn/s/blog_682b5aa1 ...
- TCP握手与socket通信细节
http://www.jianshu.com/u/5qrPPM http://www.jianshu.com/p/f86512230707
- AngularJS的增删改查、state嵌套案例,不涉及服务端
本篇实践一个案例,大致是:左边有导航菜单,右边显示列表,并可对列表项编辑或删除,也可添加新的列表项.借此,可体会到:如何组织可扩展的AngualrJS文件结构,如何点击左侧菜单项右侧显示相应内容,an ...
- AngularJS使用OData请求ASP.NET Web API资源的思路
本篇整理AngularJS使用OData请求ASP.NET Web API资源的思路. 首先给ASP.NET Web API插上OData的翅膀,通过NuGet安装OData. 然后,给control ...
- Struts2标签的<s:set>标签与JSTL的<c:set>标签
<s:set>标签 set标签 用于将某个值放入指定范围内.例如application.session范围等. 当某个值所在的对象图深度非常深时,例如如下:person.worker.wi ...
- Android:调用其他程序中的activity和Permission Denial: starting Intent 错误解决办法
今天想调试多个task中栈的情况,在测试程序中调用另一个程序的activity, 代码片段如下: btnStartX=(Button)findViewById(R.id.btnStartX); btn ...
- C#使用ProtocolBuffer(ProtoBuf)进行Unity中的Socket通信
首先来说一下本文中例子所要实现的功能: 基于ProtoBuf序列化对象 使用Socket实现时时通信 数据包的编码和解码 下面来看具体的步骤: 一.Unity中使用ProtoBuf 导入DLL到Uni ...
- 犯罪心理第一季/全集Criminal Minds迅雷下载
本季Criminal Minds Season1(2005)看点:<犯罪心理>是CBS在2005年9月22日首播的犯罪剧情系列剧,描述了FBI位于维吉尼亚州匡提科总部下属的BAU(行为分析 ...