[英]Heroku sending ping with SingalR-websocket error
Hello I uploaded a server asp.net core 3.1 https://networkscanner.herokuapp.com/ ping checker to Heroku and when i push the button to check i get Heroku error
重要的是要注意当服务器在我的本地主机上时他很好
2020-04-11T12:06:01.928201+00:00 app[web.1]: ---> System.PlatformNotSupportedException: The system's ping utility could not be found.
2020-04-11T12:06:01.928202+00:00 app[web.1]: at System.Net.NetworkInformation.Ping.GetPingProcess(IPAddress address, Byte[] buffer, PingOptions options)
2020-04-11T12:06:01.928202+00:00 app[web.1]: at System.Net.NetworkInformation.Ping.SendWithPingUtility(IPAddress address, Byte[] buffer, Int32 timeout, PingOptions options)
这是我的代码
async void SendPing()
{
Ping pingSender = new Ping();
int timeout = 10000;
string d = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
byte[] buffer = Encoding.ASCII.GetBytes(d);
PingOptions options = new PingOptions(64, true);
PingReply reply = pingSender.Send(this.numbers.Address, timeout, buffer, options);
if (reply.Status == IPStatus.Success)
{
endPoint.ip = reply.Address.ToString();
endPoint.isUP = true;
endPoint.ms = reply.RoundtripTime.ToString();
result.status = 200;
result.message = "OK";
result.endPoint = endPoint;
await Clients.All.SendAsync("Send", result);
}
else
{
endPoint.ip = reply.Address.ToString();
result.message = reply.Status.ToString();
endPoint.isUP = false;
result.status = 400;
result.endPoint = endPoint;
await Clients.All.SendAsync("Send", result);
}
}
return result;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.