【发布时间】:2019-06-07 08:35:41
【问题描述】:
我正在编写一个 Web 应用程序,它将托管在 Raspberry PI 上的 Electron 中。 Raspberry PI 附加了一个指纹扫描仪,它返回一个字符串,我需要检查指纹是否已在另一台服务器上的数据库中注册。我通过调用网络上托管的 WCF 服务方法来执行此操作。
现在的问题是调用 WCF 服务时,我在 1 分钟后超时(默认超时),但当我在本地计算机上运行应用程序时它可以工作。
服务代码:
[ServiceContract(Namespace = "http://192.168.0.154:8733/GlauxSoft.SnackBox.WebService/")]
public interface IService
{
[OperationContract]
Fingerprint GetFingerprintByUniqueId(string uniqueId);
}
public class Service : IService
{
public Fingerprint GetFingerprintByUniqueId(string uniqueId)
{
// This is just a DataBase call, nothing extraordinarily expensive
using (EvidenceSessionHelper.CreateDefaultWebServiceSession())
{
return Fingerprint.MapAuthentifizierungToWebServiceFingerprint(QueryAuthentifizierung.GetFingerprintByUniqueId(uniqueId));
}
}
}
消费者代码:
[ServiceContract(Namespace = "http://192.168.0.154:8733/GlauxSoft.SnackBox.WebService/", ConfigurationName = "ISnackBoxService")]
public interface ISnackBoxService
{
[OperationContract(
Action ="http://192.168.0.154:8733/GlauxSoft.SnackBox.WebService/IService/GetFingerprintByUniqueId",
ReplyAction = "http://192.168.0.154:8733/GlauxSoft.SnackBox.WebService/IService/GetFingerprintByUniqueIdResponse")]
Fingerprint GetFingerprintByUniqueId(string uniqueId);
}
public class ServiceClient : ClientBase<IService>, IService
{
public SnackBoxServiceClient() :
base(GetDefaultBinding(), GetDefaultEndpointAddress())
{
Endpoint.Name = EndpointConfiguration.BasicHttpBinding_ISnackBoxService.ToString();
}
public enum EndpointConfiguration
{
BasicHttpBinding_ISnackBoxService
}
public Fingerprint GetFingerprintByUniqueId(string uniqueId)
{
return Channel.GetFingerprintByUniqueId(uniqueId);
}
}
消费者是一个用 .NET Core 3 Preview 5 编写的 ASP.NET Razor 应用
我这样调用消费者代码:
var service = new ServiceClient();
var evdFingerprint = service.GetFingerprintByUniqueId("Test String"); // <-- Runs for 1 minute and throws the TimeoutException
这是堆栈跟踪:
System.TimeoutException:请求通道在 00:01:00 之后尝试发送超时。增加传递给 Request 调用的超时值或增加 Binding 上的 SendTimeout 值。分配给此操作的时间可能是较长超时的一部分。 ---> System.TimeoutException:对“http://192.168.0.154:8733/GlauxSoft.SnackBox.WebService/”的 HTTP 请求已超过分配的超时时间 00:01:00。分配给此操作的时间可能是较长超时的一部分。 在 System.ServiceModel.Channels.HttpChannelFactory`1.HttpClientRequestChannel.HttpClientChannelAsyncRequest.SendRequestAsync(消息消息,TimeoutHelper timeoutHelper) 在 System.ServiceModel.Channels.RequestChannel.RequestAsync(消息消息,TimeSpan 超时)
编辑:我已经做了一些进一步的测试,似乎对我的本地机器的任何 HTTP 请求都没有像 wget 192.168.0.154:5106 -o index.html 那样通过,并且使用wireshark 监控我的网络流量也没有向我显示对我的电脑的任何 GET 请求,并且转到 https://192.168.0.154:5106 也会超时。
但是,我可以 ping 我的本地电脑,甚至可以通过 SSH 连接到我的 Raspberry PI,我还可以与我的 Raspberry PI 建立 VNC 远程桌面会话
【问题讨论】: