gpt4 book ai didi

c# - 错误无法从传输连接读取数据。连接被对端重置。赛马林

转载 作者:太空宇宙 更新时间:2023-11-03 14:52:18 24 4
gpt4 key购买 nike

当我暂停我的应用程序并在一段时间后恢复时,我收到此错误消息:

System.IO.IOException: Unable to read data from the transport connection. Connection reset by peer ---> system.net.sockets.....

我已经分配了一个类来定义我的事件示例中的所有对象:

public class Connection: Activity
{
protected SqlConnection con;
protected string MyIp;

protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);

var prefs = Application.Context.GetSharedPreferences("Preferences", FileCreationMode.Private);
MyIp = prefs.GetString("IpAdress", null);

con = new SqlConnection("Data Source = " + MyIp + "; Initial Catalog = WiOrder; user id = admin; password = 1234;Connection Timeout=5");

}
}

这是我在事件中调用此类的方式:

public class Main : Connection
{
protected override void OnCreate(Bundle savedInstanceState)
{

base.OnCreate(savedInstanceState);
//Rest of my code
con.Open();
SqlCommand cmd = new SqlCommand (//query,con);
//.........

}
}

最佳答案

我遇到了同样的问题,并且在尝试连接到服务器时(有时)遇到了这个异常。

Unable to read data from the transport connection: Connection reset bypeer.

经过多次搜索,我找到了这个answer

Quote from the answer

This error usually means that the target machine is running, but theservice that you're trying to connect to is not available. (Either itstopped, crashed, or is busy with another request.)

In English: The connection to the machine (remote host/server/PC thatthe service runs at) was made but since the service was not availableon that machine, the machine didn't know what to do with the request.

所以,你应该检查你的网络连接

欲了解更多信息,

看看类似问题herehere

IOException

关于c# - 错误无法从传输连接读取数据。连接被对端重置。赛马林,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51236025/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com