c# - microservices 连接尝试失败,因为连接方在一段时间后没有正确响应
问题描述
我有使用微服务的客户端应用程序,我正在使用下面的代码来调用微服务。
使用(HttpClient 客户端 = 新 HttpClient())
{
var buffer = System.Text.Encoding.UTF8.GetBytes(new JavaScriptSerializer().Serialize(AttModel));
var byteContent = new ByteArrayContent(buffer);
byteContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");
string url = "http://servicename.com:60003/xxx/yyy";
HttpResponseMessage message = client.PostAsync(url, byteContent).Result;
string response = message.Content.ReadAsStringAsync().Result;
if (response != "")
{
//lblInsert.Text = "Your values inserted successfully and the Transaction Title is : " + response;
}
}
当我从此代码调用微服务时,它返回以下错误。连接尝试失败,因为连接方在一段时间后没有正确响应,或者连接失败,因为连接的主机没有响应 10.xx.yy.zz:60001
我也保持超时无限
client.Timeout = TimeSpan.FromMilliseconds(Timeout.Infinite);
之后我也关闭了防火墙,但没有用。
这个微服务在同一台机器上大摇大摆地工作。
请帮助任何人,在此先感谢!
解决方案
推荐阅读
- unit-testing - Mockk AssertionError:验证失败:调用 1 of 1
- image - 如何旋转我们用 js 创建的 img 元素?
- flutter - Dart SDK 版本不匹配
- c# - Azure 内容审查器 SDK 从列表中删除术语问题
- javascript - 如何获取父元素
- javascript - 我想要上午和下午以及时间
- android - 如何在 Kotlin 中将 HashMap 转换为 ArrayList
- ckeditor5 - CKEditor5 自定义构建镜像问题
- python - 同时运行多处理和线程
- windows-installer - Suppress Publisher 已验证用于 power point 插件的对话框弹出